Algorithm
Binary Search Tree Insertion
BST Insertion adds a new node to a Binary Search Tree while maintaining the essential BST property: all values in any node's left subtree are less than the node's value, and all values in the right subtree are greater. The algorithm traverses the tree starting from the root, making comparisons at each node to determine whether to go left or right. When it reaches a null pointer, it creates a new node in that position. This process leverages the BST structure to achieve O(log n) insertion time in balanced trees. However, in worst cases (like inserting already-sorted data), the tree can degenerate into a linked list, degrading performance to O(n). BST insertion is fundamental to building search trees and supports operations like finding minimum/maximum values, successor/predecessor relationships, and maintaining sorted data in a dynamic structure that allows for efficient insertions and deletions.