GATE Computer ScienceEasyGATE CS (PYQ pattern)
A complete binary tree stored in an array has 1000 nodes. What is its height (a single node has height 0) and how many nodes are at the last level?
- A. 10, 489
- B. 9, 489
- C. 9, 488
- D. 8, 511
Correct answer: B. 9, 489
Height = floor(log2 1000) = 9. Levels 0 to 8 hold 2^9 - 1 = 511 nodes, so the last level has 1000 - 511 = 489 nodes.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- A binary tree with 25 nodes has two pointer fields per node. How many of these 50 fields hold NULL, and how many hold NULL if the tree is…
- A circular queue of capacity 10 (array indices 0..9) keeps front and rear indices; front is the index of the first item and rear is the…
- Convert the infix expression a - b c / d + e (f - g) / h (all binary operators left-associative; and / bind tighter than + and -) to…
- Evaluate the prefix expression - + 4 5 - 9 3 / 20 + 2 3 (integer division truncating toward zero).
- Under the uniform-hashing assumption, a linear-probing table has load factor 0.5. Using the Knuth approximations, the expected number of…
- In the BST built by inserting 40, 20, 60, 10, 30, 50, 70, 25, 35, 45, 55, 65, 75, 22 in order, what are the inorder successor of 35, the…