Data Structures & AlgorithmsVery hardGATE CS · TCS NQT · Product Company SDE
Keys 12, 54, 92, 89, 71, 88, 69 are inserted in this order into an empty BST. What is the postorder traversal?
- A. [12, 54, 69, 71, 88, 89, 92]
- B. [12, 54, 92, 89, 71, 69, 88]
- C. [69, 88, 71, 89, 54, 92, 12]
- D. [69, 88, 71, 89, 92, 54, 12]
Correct answer: D. [69, 88, 71, 89, 92, 54, 12]
Insert in order to build the BST (root 12); postorder visits left, right, root, giving [69, 88, 71, 89, 92, 54, 12].
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 87, 88, 19, 50, 39, 89 one by one (sift-up on each insert). After one extract-max (move the last element…
- Which traversal of a binary search tree visits the keys in ascending order?
- Which data structure does breadth-first search (BFS) use to decide which vertex to visit next?
- How many edges does a tree with n vertices have?
- In a min-heap, where is the smallest element always found?
- What is the space needed by the adjacency-matrix representation of a graph with V vertices and E edges?