Final answer:
To construct a BST using the given data, we start by inserting the first element, 33, as the root of the tree. Then, we compare each subsequent element to the current node and insert it as the left child if it is smaller or as the right child if it is larger. To delete the nodes containing 28 and 38 from the constructed tree, we first identify the nodes to be deleted and then apply the appropriate deletion process.
Step-by-step explanation:
To construct a BST using the given data, we start by inserting the first element, 33, as the root of the tree. Then, we compare each subsequent element to the current node and insert it as the left child if it is smaller or as the right child if it is larger. The tree generated from each insertion is as follows:
Step 1: 33 (Root)
Step 2: 33 (Root) -> 28 (Left Child)
Step 3: 33 (Root) -> 28 (Left Child) -> 30 (Right Child of 28)
Step 4: 33 (Root) -> 28 (Left Child) -> 18 (Left Child of 30)
Step 5: 33 (Root) -> 28 (Left Child) -> 18 (Left Child of 30) -> 25 (Right Child of 18)
Step 6: 33 (Root) -> 28 (Left Child) -> 18 (Left Child of 30) -> 15 (Left Child of 25)
Step 7: 33 (Root) -> 28 (Left Child) -> 18 (Left Child of 30) -> 25 (Right Child of 18) -> 38 (Right Child of 25)
Step 8: 33 (Root) -> 28 (Left Child) -> 18 (Left Child of 30) -> 25 (Right Child of 18) -> 38 (Right Child of 25) -> 44 (Right Child of 38)
Step 9: 33 (Root) -> 28 (Left Child) -> 18 (Left Child of 30) -> 25 (Right Child of 18) -> 38 (Right Child of 25) -> 44 (Right Child of 38) -> 58 (Right Child of 44)
To delete the nodes containing 28 and 38 from the constructed tree, we first identify the nodes to be deleted and then apply the appropriate deletion process. The deletion scenarios are as follows:
Step 1: Deleting 28
Step 2: Deleting 38