Starting from an empty tree, construct an ordinary (non-self-balancing) Binary Search Tree after inserting the following
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Starting from an empty tree, construct an ordinary (non-self-balancing) Binary Search Tree after inserting the following
Starting from an empty tree, construct an ordinary (non-self-balancing) Binary Search Tree after inserting the following in the same order: 2, 4, 6, 8, 16, 12, 14, 10. After inserting the following: 1. What is the height of the resulting tree? 2. How many leaves are there in the resulting tree? 3. What is the successor of node 14? 4. What is the left child of node 16? 5. What is the degree of node 12? Derive the tree-walk/nod-label sequence of the resulting tree using tree walk(): 1 2 3 4 5 6 struct node { int val; }; struct node *Left; struct node *Right; // value inside your node // left child // right child 7- void tree_walk(struct node *x) { 8 + if(x != NULL) { 9 10 11 12 13 } } tree walk(x->Right) printf("%d", x->val) tree walk(x->Left) Perform tree walk(x) where x is the pointer to the root node: 1. What is the first number in the tree walk sequence? 2. What is the third number in the tree walk sequence? 3. What is the fifth number in the tree walk sequence? 4. What is the seventh number in the tree walk sequence? 5. What is the last number in the tree walk sequence?