
height-balancing
Height-balancing is a method used in binary search trees to keep the structure efficient for operations like searching, inserting, and deleting. It ensures that the difference in height between the left and right subtrees of any node stays within a small limit (typically one). By maintaining this balance, the tree remains relatively flat and prevents operations from becoming slow, as it reduces the maximum number of steps needed to find or organize data. Essentially, height-balancing keeps the tree well-shaped so that data retrieval remains quick and consistent.