Data Structures & AlgorithmsHardGATE CS
A binary search tree holds exactly the keys 41, 50, 62, 63, 68, 69, 74, 94. Which ONE of the following can be its POSTORDER traversal?
- A. 68, 41, 50, 94, 74, 69, 63, 62
- B. 63, 41, 68, 94, 74, 69, 50, 62
- C. 50, 41, 68, 94, 74, 63, 69, 62
- D. 50, 41, 68, 94, 74, 69, 63, 62
Correct answer: D. 50, 41, 68, 94, 74, 69, 63, 62
The last key is the root; the keys before it must split into a block of smaller keys followed by a block of larger keys, recursively. Only 50, 41, 68, 94, 74, 69, 63, 62 splits correctly at every level.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- A 4-ary max-heap is stored in a 0-indexed array (children of i at 4i + 1 … 4i + 4): [58, 57, 54, 33, 11, 34, 22, 42, 30, 19]. After…
- Keys 33, 11, 72, 19, 76, 71, 31, 74, 40, 37, 45 are inserted in that order into an empty BST. Then 33 is deleted and after that 37 is…
- Keys 90, 94, 89, 30, 62, 17, 99, 53 inserted in this order build a BST. How many of the 8! orderings of these same 8 keys, inserted into…
- A binary search tree holds exactly the keys 13, 19, 20, 36, 71, 73, 94, 99. Which ONE of the following sequences can be its PREORDER…
- A BST holds integer keys between 1 and 100. Which sequence CANNOT be the sequence of keys examined while searching for 44?
- A rooted tree has these parent→child edges: 56→8, 64→56, 64→24, 64→45, 24→59, 45→41, 8→2. A depth-first search starts at the root and, at…