Exams
Subjects
Classes
Home
Programming and Data Stru...
List of top Programming and Data Structures Questions on Trees
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)
GATE CS - 2026
GATE CS
Programming and Data Structures
Trees
The following sequence corresponds to the preorder traversal of a binary search tree \(T\):
50, 25, 13, 40, 30, 47, 75, 60, 70, 80, 77
The position of the element 60 in the postorder traversal of \(T\) is ______.
Note: The position begins with 1.
GATE CS - 2026
GATE CS
Programming and Data Structures
Trees
Suppose the values 10, −4, 15, 30, 20, 5, 60, 19 are inserted in that order into an initially empty binary search tree. Let \( T \) be the resulting binary search tree.
The number of edges in the path from the node containing 19 to the root node of \( T \) is
\underline{{1cm}}. {(Answer in integer)}
GATE CS - 2025
GATE CS
Programming and Data Structures
Trees
In a B+- tree where each node can hold at most four key values, a root to leaf path consists of the following nodes:
\( A = (49, 77, 83, -) \)
\( B = (7, 19, 33, 44) \)
\( C = (20^*, 22^*, 25^*, 26^*) \)
The *-marked keys signify that these are data entries in a leaf. Assume that a pointer between keys \( k_1 \) and \( k_2 \) points to a subtree containing keys in \([ k_1, k_2 )\), and that when a leaf is created, the smallest key in it is copied up into its parent. A record with key value 23 is inserted into the B+- tree. The smallest key value in the parent of the leaf that contains 25* is ___________ . (Answer in integer)
GATE CS - 2025
GATE CS
Programming and Data Structures
Trees
Consider the following algorithm tt{someAlgo
that takes an undirected graph \( G \) as input.} tt{someAlgo(G)} Let \( v \) be any vertex in \( G \). Run BFS on \( G \) starting at \( v \). Let \( u \) be a vertex in \( G \) at maximum distance from \( v \) as given by the BFS. Run BFS on \( G \) again with \( u \) as the starting vertex. Let \( z \) be the vertex at maximum distance from \( u \) as given by the BFS. Output the distance between \( u \) and \( z \) in \( G \). The output of tt{someAlgo(T)} for the tree shown in the given figure is ___________ . (Answer in integer) \begin{center} \includegraphics{q59_fig.png} \end{center}
GATE CS - 2025
GATE CS
Programming and Data Structures
Trees
A binary search tree \( T \) contains \( n \) distinct elements. What is the time complexity of picking an element in \( T \) that is smaller than the maximum element in \( T \)?
GATE CS - 2021
GATE CS
Programming and Data Structures
Trees