GATE Computer ScienceVery hardGATE CSE · UGC NET
Keys 50, 30, 70, 20, 40, 60, 80, 35, 45, 65, 10, 25, 75 are inserted in this order into an initially empty BST. Then key 30 is deleted, then key 50. A node with two children is replaced by its inorder successor (which is then removed from its old place). What is the 6th key in the preorder traversal of the final tree?
- A. 25
- B. 45
- C. 40
- D. 70
Correct answer: C. 40
After both deletions the preorder is 60, 35, 20, 10, 25, 40, 45, 70, 65, 80, 75; its 6th entry is 40.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- Keys 10, 20, 30, 40, 50, 25, 5, 4, 3, 35, 45, 60, 55, 52 are inserted in this order into an initially empty AVL tree. Count every single…
- A hash table of size 11 uses h(k) = k mod 11 with quadratic probing: the i-th probe examines slot (h(k) + i²) mod 11, for i = 0, 1, 2, ……
- The integers 1, 2, 3, 4, 5, 6 are pushed in this order onto a stack; pops can be interleaved with pushes at any time and every element is…
- How many structurally distinct binary trees (left and right children distinguished) with exactly 7 nodes have height exactly 3, where…
- int cnt = 0; for (int i = 0; i < 100; i++) for (int x = i; x; x = x & (x - 1)) cnt++; What is the final value of cnt?
- int n = 200, cnt = 0; for (int i = 1; i <= n; i = 2) for (int j = i; j <= n; j += i) cnt++; What is the value of cnt after the loops finish?