GATE Computer ScienceEasyGATE CS (PYQ pattern)
A rooted tree has 6 nodes with 2 children, 5 nodes with 3 children and 4 nodes with 4 children; every other node is a leaf. How many nodes does the tree have in all?
- A. 43
- B. 45
- C. 35
- D. 44
Correct answer: D. 44
Edges = total children = 12 + 15 + 16 = 43, and nodes = edges + 1 = 44, matching leaves 29 plus internal 15.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- How many structurally different binary search trees can be built on the keys 1..7 such that the height is at most 3 (a single node has…
- Among all 429 structurally different binary search trees on the keys 1 to 7, in how many is key 3 a leaf?
- Keys 50, 30, 80, 20, 40, 70, 90, 10, 25, 35, 45, 5, 12, 22, 27 are inserted in this order into an empty BST. An iterative preorder…
- Keys 50, 30, 80, 20, 40, 70, 90, 10, 25, 35, 45, 5, 12, 22, 27 are inserted in this order into an empty BST. Its level-order traversal…
- Which one of the following sequences can NOT be the postorder traversal of a binary search tree with distinct keys?
- Keys 1 to 6 are inserted into an empty BST in each of the 720 possible orders. For how many orders is the height of the resulting tree…