Let T be a full binary tree with 8 leaves. (A full binary tree has every level full.) Suppose two leaves a and b of T are chosen uniformly and independently at random. The expected value of the distance between a and b in T (i.e., the number of edges in the unique path between a and b) is (rounded off to 2 decimal places) ___________ .
Data Structures
GATE 2019
Data Structures
gate 2018
Data Structures
gate 2018
Data Structures
gate 2018
Graphs
Data Structures
gate 2018
Heap-Tree
A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are
performed efficiently. Which one of the following statements is CORRECT (n refers to the
number of items in the queue)?
Both operations can be performed in O(1) time
At most one operation can be performed in O(1) time but the worst case time for
the other operation will be Ω(n)
The worst case time complexity for both operations will be Ω(n)
Worst case time complexity for both operations will be Ω(logn)
Data Structures
gate 2016 set 1
Data Structures
gate 2016 set 1
Let G be a weighted connected undirected graph with distinct positive edge weights. If every
edge weight is increased by the same value, then which of the following statements is/are
TRUE?
P: Minimum spanning tree of G does not change
Q: Shortest path between any pair of vertices does not change
Data Structures
gate 2016 set 1
Graphs
An operator delete(i) for a binary heap data structure is to be designed to delete the item in
the i-th node. Assume that the heap is implemented in an array and i refers to the i-th index
of the array. If the heap tree has depth d (number of edges on the path from the root to the
farthest leaf), then what is the time complexity to re-fix the heap efficiently after the removal
of the element?
Data Structures
gate 2016 set 1
Data Structures
gate 2016 set 1
Graphs
Data Structures
gate 2016 set 1
Breadth First Search (BFS) is started on a binary tree beginning from the root vertex. There is
a vertex t at a distance four from the root. If t is the n-th vertex in this BFS traversal, then the
maximum possible value of n is _____________
Data Structures
gate 2016
Data Structures
gate 2016
Linked-List
The number of ways in which the numbers 1, 2, 3, 4, 5, 6, 7 can be inserted in an empty binary
search tree, such that the resulting tree has height 6, is __________________
Note: The height of a tree with a single node is 0.
Data Structures
gate 2016
Data Structures
gate 2016
Graphs
Let T be a binary search tree with 15 nodes. The minimum and maximum possible heights of T are:
Note: The height of a tree with a single node is 0.
Data Structures
GATE 2017 SET 1
Binary-Trees
Consider the C code fragment given below.
typedef struct node
{
int data;
node* next ;
} node;
void join(node* m, node* n)
{
node* p = n;
while (p->next != NULL)
{
p = p->next;
}
p–>next = m;
}
Assuming that m and n point to valid NULL- terminated linked lists, invocation of join will
append list m to the end of list n for all inputs
either cause a null pointer dereference or append list m to the end of list n
cause a null pointer dereference for all inputs
append list n to the end of list m for all inputs.
Data Structures
GATE 2017 SET 1
Linked-List
A Circular queue has been implemented using singly linked list where each node consists of a value and a pointer to next node. We maintain exactly two pointers FRONT and REAR pointing to the front node and rear node of queue. Which of the following statements is/are correct for circular queue so that insertion and deletion operations can be performed in O(1) i.e. constant time.
I. Next pointer of front node points to the rear node.
II. Next pointer of rear node points to the front node.
Data Structures
GATE 2017 SET2
The height of a tree is the length of the longest root-to-leaf path in it. The maximum and minimum
number of nodes in a binary tree of height 5 are
Data Structures
GATE 2015 SET 1
Trees
Which of the following is/are correct inorder traversal sequence(s) of binary search tree(s)?
I. 3, 5, 7, 8, 15, 19, 25
II. 5, 8, 9, 12, 10, 15, 25
III. 2, 7, 10, 8, 14, 16, 20
IV. 4, 6, 7, 9 18, 20, 25
Data Structures
GATE 2015 SET 1