Data Structures & AlgorithmsModerateGATE CSE · Trees
Keys 45, 25, 65, 15, 35, 55, 75, 30 are inserted in this order into an empty binary search tree. What is its postorder traversal?
- A. 45 25 15 35 30 65 55 75
- B. 15 30 35 25 55 75 65 45
- C. 45 25 65 15 35 55 75 30
- D. 15 25 30 35 45 55 65 75
Correct answer: B. 15 30 35 25 55 75 65 45
Postorder visits left subtree, right subtree, then the node: 15, 30, 35, 25, 55, 75, 65, 45.
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
- What is the maximum number of nodes in a binary tree of height 5, where the height is the number of edges on the longest root-to-leaf path?
- A complete binary tree stored level by level has exactly 40 nodes. How many of them are leaves?
- Keys 14, 8, 11, 5, 9, 3, 12 are inserted one at a time into an initially empty binary min-heap kept in an array. What does the array hold…
- An undirected graph has edges A-B, A-C, B-D, B-E, C-E, C-F, D-G, E-G, F-G. Neighbours are always visited in alphabetical order. What is…
- A binary tree has inorder traversal D B E A F C and postorder traversal D E B F C A. What is its preorder traversal?
- How many structurally different binary search trees can be built from 5 distinct keys?