GATE CS 2026 Set 1 — Question 40
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.MCQ+2 / -0.67HardBinary Tree PropertiesBinary Search TreesTreesProgramming & Data Structures
Programming & Data Structures → Trees → Binary Search Trees
Last updated
Question
Let be the set of all integers from 1 to 15. Consider any order of insertion of the elements of into a binary search tree that creates a complete binary tree.Which one of the following elements can NEVER be the third element that is inserted?
Correct answer
(D) 5
Solution
A complete binary tree with 15 nodes (values 1 to 15) is a perfect binary tree. The structure and values of the nodes are fixed:
(A) 4: Possible (Sequence: 8, 12, 4)
(B) 2: Possible (Sequence: 8, 4, 2)
(C) 10: Possible (Sequence: 8, 12, 10)
(D) 5: 5 is a child of 6 in the perfect tree. To insert 5, 6 must already be present or 5 must be inserted in a way that leads to its correct position. If 5 is the 3rd element (Sequence: 8, , 5):
- The root is the median, 8.
- The left child of 8 is 4, and the right child of 8 is 12.
- The children of 4 are 2 and 6. The children of 12 are 10 and 14.
- The leaves are 1, 3, 5, 7, 9, 11, 13, 15.
- If the 2nd element is 4, the 3rd element can be 12 (the other child of 8) or a child of 4 (2 or 6).
- If the 2nd element is 12, the 3rd element can be 4 (the other child of 8) or a child of 12 (10 or 14).
(A) 4: Possible (Sequence: 8, 12, 4)
(B) 2: Possible (Sequence: 8, 4, 2)
(C) 10: Possible (Sequence: 8, 12, 10)
(D) 5: 5 is a child of 6 in the perfect tree. To insert 5, 6 must already be present or 5 must be inserted in a way that leads to its correct position. If 5 is the 3rd element (Sequence: 8, , 5):
- If : , so 5 goes to the right of 4. In the perfect tree, the right child of 4 is 6. So 5 would occupy 6's spot, which is incorrect.
- If : , so 5 goes to the left of 8. The left child of 8 is 4. So 5 would occupy 4's spot, which is incorrect.
Continue learning with Success Tracker
A step still unclear? Work through it with support
Use Success Tracker to ask about the reasoning, then try another GATE CS question to check your understanding.
AI-powered practice· Unlimited practice on eligible plans
- PYQs with solutions
- Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
- Practice that adapts
- Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
- AI doubt support
- Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.
Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.
This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.
More questions on Trees
2026 Set 2 Q12The set T represents various traversals over binary tree. The set S represents the order of…2026 Set 2 Q19Consider the following three ANSI-C programs, P1, P2, and P3. P1 [code] P2 [code] **P3**…2026 Set 1 Q23Let be an odd number greater than 100. Consider a binary minheap with elements stored in an…2026 Set 1 Q24Consider a hash table that is initially empty. The hash table is maintained…2026 Set 1 Q27Consider the following C statements: Which of the following options is/are correct? [figure]