Tree Data Structures questions — page 1 of 3

Q23

GATE CS 2026 CS-1Tree Data StructuresMSQ1 mark
Let nn be an odd number greater than 100. Consider a binary minheap with nn elements stored in an array PP whose index starts from 1.

Which of the following indices of PP do/does NOT correspond to any leaf node of the minheap?
More than one option can be correct.
Show answer without attempting

Answer: B, C

Q33

GATE CS 2026 CS-1Tree Data StructuresNAT1 mark
The height of a binary tree is the number of edges in the longest path from the root to a leaf in the tree. The maximum possible height of a full binary tree with 23 nodes is _________. (answer in integer)
Show answer without attempting

Answer: 11

Q40

GATE CS 2026 CS-1Tree Data StructuresMCQ2 marks−2/3 if wrong
Let PP be the set of all integers from 1 to 15. Consider any order of insertion of the elements of PP 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?
Show answer without attempting

Answer: D

Q62

GATE CS 2026 CS-1Tree Data StructuresNAT2 marks
The following sequence corresponds to the preorder traversal of a binary search tree TT:

50, 25, 13, 40, 30, 47, 75, 60, 70, 80, 77

The position of the element 60 in the postorder traversal of TT is ______. (answer in integer)

Note: The position begins with 1.
Show answer without attempting

Answer: 7

Q12

GATE CS 2026 CS-2Tree Data StructuresMCQ1 mark−1/3 if wrong
The set T represents various traversals over binary tree. The set S represents the order of visiting nodes during a traversal.

| T | S |
|---|---|
| I: Inorder | L: left subtree, node, right subtree |
| II: Preorder | M: node, left subtree, right subtree |
| III: Postorder | N: left subtree, right subtree, node |

Which one of the following is the correct match from T to S ?
Show answer without attempting

Answer: A

Q49

GATE CS 2026 CS-2Tree Data StructuresMSQ2 marks
Consider a binary search tree (BST) with nn leaf nodes (n>0n > 0). Given any node VV, the key present in the node is denoted as Val(V)Val(V). All the keys present in the given BST are distinct. The keys belong to the set of real numbers.

For a node VV, let Suc(V)Suc(V) denote the node that is its inorder successor. If a node VV does not have an inorder successor, then Suc(V)Suc(V) is NULLNULL. As there are no duplicates, if Suc(V)Suc(V) is not NULLNULL, then Val(V)<Val(Suc(V))Val(V) < Val(Suc(V)).

Corresponding to every leaf node LiL_i that has a non-NULLNULL Suc(Li)Suc(L_i), a new key kik_i with the following property is to be inserted into the BST.

Val(Li)<ki<Val(Suc(Li))Val(L_i) < k_i < Val(Suc(L_i))

Let KK represent the list of all such new keys to be inserted into the BST.

Which of the following statements is/are true?
More than one option can be correct.
Show answer without attempting

Answer: A, C

Q26

GATE CS 2025 CS-1Tree Data StructuresMSQ1 mark
Which of the following statement(s) is/are TRUE for any binary search tree (BST) having nn distinct integers?
More than one option can be correct.
Show answer without attempting

Answer: A, B

Q35

GATE CS 2025 CS-1Tree Data StructuresNAT1 mark
The height of any rooted tree is defined as the maximum number of edges in the path from the root node to any leaf node.
Suppose a Min-Heap TT stores 32 keys. The height of TT is _____________. (Answer in integer)
Show answer without attempting

Answer: 5

Q13

GATE CS 2025 CS-2Tree Data StructuresMCQ1 mark−1/3 if wrong
Consider a binary tree TT in which every node has either zero or two children. Let n>0n > 0 be the number of nodes in TT.

Which ONE of the following is the number of nodes in TT that have exactly two children?
Show answer without attempting

Answer: B

Q35

GATE CS 2025 CS-2Tree Data StructuresNAT1 mark
Suppose the values 10,−4,15,30,20,5,60,1910, -4, 15, 30, 20, 5, 60, 19 are inserted in that order into an initially empty binary search tree. Let TT be the resulting binary search tree.
The number of edges in the path from the node containing 19 to the root node of TT is ___________. (Answer in integer)
Show answer without attempting

Answer: 4

Q41

GATE CS 2024 CS-1Tree Data StructuresMCQ2 marks−2/3 if wrong
An array [82, 101, 90, 11, 111, 75, 33, 131, 44, 93] is heapified. Which one of the following options represents the first three elements in the heapified array?
Show answer without attempting

Answer: D

Q43

GATE CS 2024 CS-1Tree Data StructuresMCQ2 marks−2/3 if wrong
Consider a binary min-heap containing 10510^5 distinct elements. Let kk be the index (in the underlying array) of the maximum element stored in the heap. The number of possible values of kk is
Show answer without attempting

Answer: A

Q39

GATE CS 2024 CS-2Tree Data StructuresMCQ2 marks−2/3 if wrong
You are given a set VV of distinct integers. A binary search tree TT is created by inserting all elements of VV one by one, starting with an empty tree. The tree TT follows the convention that, at each node, all values stored in the left subtree of the node are smaller than the value stored at the node. You are not aware of the sequence in which these values were inserted into TT, and you do not have access to TT.

Which one of the following statements is TRUE?
Show answer without attempting

Answer: A

Q12

GATE CS 2023 CSTree Data StructuresMCQ1 mark−1/3 if wrong
Which one of the following sequences when stored in an array at locations A[1],…,A[10]A[1], \dots, A[10] forms a max-heap?
Show answer without attempting

Answer: B

Q46

GATE CS 2023 CSTree Data StructuresMCQ2 marks−2/3 if wrong
Let AA be a priority queue for maintaining a set of elements. Suppose AA is implemented using a max-heap data structure. The operation EXTRACT-MAX(A) extracts and deletes the maximum element from AA. The operation INSERT(A, key) inserts a new element key in AA. The properties of a max-heap are preserved at the end of each of these operations.

When AA contains nn elements, which one of the following statements about the worst case running time of these two operations is TRUE?
Show answer without attempting

Answer: B

Q47

GATE CS 2023 CSTree Data StructuresMCQ2 marks−2/3 if wrong
Consider the C function foo and the binary tree shown.
typedef struct node {
int val;
struct node *left, *right;
} node;
int foo(node *p) {
int retval;
if (p == NULL)
return 0;
else {
retval = p->val + foo(p->left) + foo(p->right);
printf("%d ", retval);
return retval;
}
}
When foo is called with a pointer to the root node of the given binary tree, what will it print?
Question figure
Show answer without attempting

Answer: C

Q28

GATE CS 2022 CSTree Data StructuresNAT1 mark
Suppose a binary search tree with 1000 distinct elements is also a complete binary tree. The tree is stored using the array representation of binary heap trees. Assuming that the array indices start with 0, the 3rd3^{\text{rd}} largest element of the tree is stored at index_____________
Show answer without attempting

Answer: 509

Q10

GATE CS 2021 CS-1Tree Data StructuresMCQ1 mark−1/3 if wrong
A binary search tree TT contains nn distinct elements. What is the time complexity of picking an element in TT that is smaller than the maximum element in TT?
Show answer without attempting

Answer: D

Q2

GATE CS 2021 CS-2Tree Data StructuresMCQ1 mark−1/3 if wrong
Let HH be a binary min-heap consisting of nn elements implemented as an array. What is the worst case time complexity of an optimal algorithm to find the maximum element in HH?
Show answer without attempting

Answer: C

Q16

GATE CS 2021 CS-2Tree Data StructuresNAT1 mark
Consider a complete binary tree with 7 nodes. Let AA denote the set of first 3 elements obtained by performing Breadth-First Search (BFS) starting from the root. Let BB denote the set of first 3 elements obtained by performing Depth-First Search (DFS) starting from the root.
The value of ∣A−B∣|A - B| is ____________.
Show answer without attempting

Answer: 1

0/200 correct0 marks

Related topics in Programming and Data Structures