Company: Bounteous × Accolite_28oct
Difficulty: medium
BST Leaf Nodes after Operations You maintain a Binary Search Tree (BST) that starts out empty and is changed by a sequence of operations. Each operation either inserts a value or deletes a value. After the whole sequence has been applied, report the values stored in the leaf nodes of the final tree, from left to right. BST Invariant For any node holding value v , every value in its left subtree is less than v and every value in its right subtree is greater than v . The tree satisfies this rule before and after every operation. Insertion insert x starts at the root and walks down: at a node holding v it moves to the left child when x < v and to the right child otherwise. The new node holding x is placed at the first empty position reached. When the tree is empty, x becomes the root. Deletion delete x first locates the node holding x , then removes it by one of three cases: The node has a right child. The node is replaced by that right child, which moves up into the node's positi