Data Structures & AlgorithmsVery hardGATE CS · Product-company placement
A binary tree with distinct labels has INORDER E D I C A G H B F and LEVEL-ORDER I D H E G B C F A. What is its postorder traversal?
- A. I D E H G C A B F
- B. F B A C G H E D I
- C. E D A C G F B H I
- D. A F C B G E H D I
Correct answer: C. E D A C G F B H I
The first level-order label I is the root; its position in the inorder splits the left and right subtrees, and the earliest level-order label inside each part is that part's root. Rebuilding gives postorder E D A C G F B H I.
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
- The boolean expression F & T | T & T (T = true, F = false, & = AND, | = OR, ^ = XOR) can be fully parenthesised in 5 ways. In how many of…
- What is the maximum flow from S to T in the network with directed capacities A→C (5), B→A (10), B→C (13), B→T (9), C→T (12), S→A (14), S→B…
- The boolean expression F & F & T ^ T (T = true, F = false, & = AND, | = OR, ^ = XOR) can be fully parenthesised in 5 ways. In how many of…
- Keys 60, 41, 30, 69, 50, 54, 52, 55, 21 are inserted in that order into an empty AVL tree. What is the preorder traversal of the final tree?
- The weighted undirected graph A–B (1), A–C (6), A–E (3), B–D (1), C–D (2), C–E (5), D–E (3) has repeated weights. How many different…
- The words stem, stack, step, star, start are inserted into an empty trie (one node per character, shared prefixes share nodes, plus a…