Data Structures & AlgorithmsHardGATE CS · TCS NQT · Product Company SDE
Keys 81, 18, 92, 48, 71, 55, 44, 41 are inserted in this order into an empty BST. What is the postorder traversal?
- A. [18, 41, 44, 48, 55, 71, 81, 92]
- B. [41, 44, 55, 71, 48, 18, 92, 81]
- C. [81, 18, 48, 44, 41, 71, 55, 92]
- D. [41, 44, 55, 71, 48, 92, 18, 81]
Correct answer: B. [41, 44, 55, 71, 48, 18, 92, 81]
Insert in order to build the BST (root 81); postorder visits left, right, root, giving [41, 44, 55, 71, 48, 18, 92, 81].
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 max-heap is built by inserting 55, 85, 57, 63, 32, 19, 91, 12 one by one (sift-up on each insert). After one extract-max (move the last…
- A max-heap is built by inserting 73, 97, 96, 27, 78, 89, 18 one by one (sift-up on each insert). After one extract-max (move the last…
- A DAG has edges A→B, A→C, B→D, C→E, A→D, B→C. Using Kahn's algorithm (always picking the smallest-labelled vertex among those currently…
- What is the time complexity of searching for a word of length m in a trie that stores n words, independent of n?
- An undirected graph has adjacency lists A:BCEF B:AD C:ADF D:BCF E:A F:ACD. Neighbours are always explored in alphabetical order. Which is…
- An undirected graph has edges (u–v: weight) A–B:14, A–C:13, C–D:14, B–E:11, C–E:4, B–D:3. What is the weight of its minimum spanning tree?