50 Pyq DS
50 Pyq DS
SWETA KUMARI
TELEGRAM CHANNEL FOR NOTES :
https://t.me/gatecsitunacademy
1 YEAR : 14,298/-
HELLOSONU01
1 YEAR : 21,999/-
HELLOSONU01
Benefits of Plus Subscription
1. Daily Live Classes
2. Recorded lectures
3. Daily lectures PDF notes
4. LIVE Doubt clearing session twice a week
5. 5600+ practice questions with detailed solutions
6. 750+ test series including topic wise, subject wise and full length
7. Digital Chapter wise Notes of every subject
8. Daily Practice Problems just after class in a group
9. Access to all 15+ GATE CS IT educators LIVE Classes
10.Access to all Recorded lectures of previous top educators
INSERT(A, key):
The INSERT(A, key) operation involves the following steps:
•Add the new element at the end of the heap.
•Restore the max-heap property by "bubbling up" the new element, which ensures it is correctly placed. Bubbling up could
potentially involve comparing and swapping elements up through the height of the heap. This process also takes O(log(n)) time in
the worst case.
Therefore, the worst-case running time for INSERT(A, key) is O(log(n)).
Conclusion:
The correct choice is:
Option B
If a heap has 1023 elements, it'll contain 512 leaves and since it is a MIN-
HEAP, the maximum will be present in the leaves.
We can visualise it this way. At each level starting with root level, number of
elements are
Which one of the following statements is TRUE about the time complexity of algorithms that solve the above problem in O(1) space?
A
The best algorithm for the problem takes θ(n) time in the worst case.
B
The best algorithm for the problem takes θ(n log n) time in the worst case.
C
The best algorithm for the problem takes θ(n2) time in the worst case.
D
It is not possible to reverse a singly linked list in O(1) space.
GATE CSE 2024 Set 1
Numerical
+1
-0
Consider the operator precedence and associativity rules for the integer arithmetic operators given in the table below.
Stack S1
400 (Top)
300
200
100
GATE CSE 2024 Set 2
MCQ (More than One Correct Answer)
+2
Let S1 and S2 be two stacks. S1 has capacity of 4 elements. S2 has capacity of 2 elements. S1 already has 4 elements: 100, 200, 300, and 400,
whereas S2 is empty, as shown below.
Stack S1
B,C,D
400 (Top)
300
200
100
D
GATE CSE 2023
Numerical
+2
-0
Consider a sequence a of elements a0=1,a1=5,a2=7,a3=8,a4=9, and a5=2. The following operations are performed on a stack S and a queue Q,
both of which are initially empty.
I: push the elements of a from a0 to a5 in that order into S.
II: enqueue the elements of a from a0 to a5 in that order into Q.
III: pop an element from S.
IV: dequeue an element from Q.
V: pop an element from S.
VI: dequeue an element from Q.
VII: dequeue an element from Q and push the same
VIII: Repeat operation VII three times.
IX: pop an element from S.
X: pop an element from S.
The top element of S after executing the above operations is ____________.
GATE CSE 2023
Numerical
+2
-0
Consider a sequence a of elements a0=1,a1=5,a2=7,a3=8,a4=9, and a5=2. The following operations are performed on a stack S and a queue Q,
both of which are initially empty.
I: push the elements of a from a0 to a5 in that order into S.
II: enqueue the elements of a from a0 to a5 in that order into Q.
III: pop an element from S.
IV: dequeue an element from Q.
V: pop an element from S. 8
VI: dequeue an element from Q.
VII: dequeue an element from Q and push the same
VIII: Repeat operation VII three times.
IX: pop an element from S.
X: pop an element from S.
The top element of S after executing the above operations is ____________.
GATE CSE 2022
Numerical
+2
-0
Consider the queues Q1 containing four elements and Q2 containing none (shown as the Initial State in the figure). The only operations
allowed on these two queues are Enqueue (Q, element) and Dequeue (Q). The minimum number of Enqueue operations on
Q1 required to place the elements of Q1 in Q2 in reverse order (shown as the Final State in the figure) without using any additional
storage is ______________.
GATE CSE 2022
Numerical
+2
-0
Consider the queues Q1 containing four elements and Q2 containing none (shown as the Initial State in the figure). The only operations
allowed on these two queues are Enqueue (Q, element) and Dequeue (Q). The minimum number of Enqueue operations on
Q1 required to place the elements of Q1 in Q2 in reverse order (shown as the Final State in the figure) without using any additional
storage is ______________.
0
6
B
GATE | GATE CS 2021
#include
#include
struct Node{
int value;
struct Node *next;};
int main( ) {
struct Node *boxE, *head, *boxN; int index=0;
boxE=head= (struct Node *) malloc(sizeof(struct Node));
head → value = index;
for (index =1; index<=3; index++){
boxN = (struct Node *) malloc (sizeof(struct Node));
boxE → next = boxN;
boxN → value = index;
boxE = boxN; }
for (index=0; index<=3; index++) {
printf(“Value at index %d is %d\n”, index, head → value);
head = head → next;
printf(“Value at index %d is %d\n”, index+1, head → value); } }
Which one of the following statements below is correct about the program?
(A) Upon execution, the program creates a linked-list of five nodes
(B) Upon execution, the program goes into an infinite loop
(C) It has a missing return which will be reported as an error by the compiler
(D) It dereferences an uninitialized pointer that may result in a run-time error
GATE | GATE CS 2021
#include Explanation:
#include
struct Node{
int value; When you debug loop 1 you will get the linked list of size 4
struct Node *next;};
int main( ) { In the second loop value will be printed 0 0 1 1 2 2 3 3 after
struct Node *boxE, *head, *boxN; int index=0;
boxE=head= (struct Node *) malloc(sizeof(struct Node)); that head will be pointing to some random location and result
head → value = index; in run-time error.
for (index =1; index<=3; index++){ Correct Option (D)
boxN = (struct Node *) malloc (sizeof(struct Node));
boxE → next = boxN;
boxN → value = index;
boxE = boxN; }
for (index=0; index<=3; index++) {
printf(“Value at index %d is %d\n”, index, head → value);
head = head → next;
printf(“Value at index %d is %d\n”, index+1, head → value); } }
Which one of the following statements below is correct about the program?
(A) Upon execution, the program creates a linked-list of five nodes
(B) Upon execution, the program goes into an infinite loop
(C) It has a missing return which will be reported as an error by the compiler
(D) It dereferences an uninitialized pointer that may result in a run-time error
Consider a complete binary tree where the left and the right subtrees of the root are max-heaps. The lower
bound for the number of operations to convert the tree to a heap is
(A) Ω(logn)
(B) Ω(n)
(C) Ω(nlogn)
(D) Ω(n2)
GATE-CS-2015
Consider a complete binary tree where the left and the right subtrees of the root are max-heaps. The lower
bound for the number of operations to convert the tree to a heap is
(A) Ω(logn)
(B) Ω(n)
(C) Ω(nlogn)
(D) Ω(n2)
Answer: (A)
N items are stored in a sorted doubly linked list. For a delete operation, a pointer is provided to the record to be
deleted. For a decrease-key operation, a pointer is provided to the record on which the operation is to be performed.
An algorithm performs the following operations on the list in this order: Θ(N) delete,O(logN) insert, O(logN) find, and
Θ(N) decrease-key. What is the time complexity of all these operations put together?
A priority queue Q is used to implement a stack S that stores characters. PUSH(C) is implemented as INSERT(Q, C, K) where K is an
appropriate integer key chosen by the implementation. POP is implemented as DELETEMIN(Q). For a sequence of operations, the
keys chosen are in
(A) Non-increasing order
(B) Non-decreasing order
(C) strictly increasing order
(D) strictly decreasing order
Answer: (D)
Explanation: We are implementing a STACK using Priority Queue. Note that Stack implementation is always last in first out (LIFO)
order.
As given “POP is implemented as DELETEMIN(Q)” that means Stack returns minimum element always.
So, we need to implement PUSH(C) using INSERT(Q, C, K) where K is key chosen from strictly-decreasing order(only this order will
ensure stack will return minimum element when we POP an element). That will satify Last In First Out (LIFO) property of stack.
Option (A) non-increasing order can not be true because two same (identical) numbers can not have same priority as priority
should be distinguishable for each number.
p
GATE 2014 Q R
GATE 2014 Q R
823^/23*+51*-
Note that ^ is the exponentiation operator. The top two elements of the stack after the first * is evaluated are:
(A) 6, 1
(B) 5, 7
(C) 3, 2
(D) 1, 5
GATE | GATE-CS-2007
The following postfix expression with single digit operands is evaluated using a stack:
823^/23*+51*-
Note that ^ is the exponentiation operator. The top two elements of the stack after the first * is evaluated are:
(A) 6, 1
(B) 5, 7
(C) 3, 2
(D) 1, 5
Answer: (A)
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)?
GATE 2016
(A) Both operations can be performed in O(1) time
(B) At most one operation can be performed in O(1) time but the worst case time for the other operation
will be Ω(n)
(C) The worst case time complexity for both operations will be Ω(n)
(D) Worst case time complexity for both operations will be Ω(log n)
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)?
Which one of the following is the time complexity of the most time-efficient implementation of ‘enqueue’ and ‘dequeue,
respectively, for this data structure?
(A) Θ(1), Θ(1)
(B) Θ(1), Θ(n)
(C) Θ(n), Θ(1) …….
(D) Θ(n), Θ(n)
head tail
GATE 2018
A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer, as shown
in the figure. Let n denote the number of nodes in the queue. Let ‘enqueue’ be implemented by inserting a new node at
the head, and ‘dequeue’ be implemented by deletion of a node from the tail.
Which one of the following is the time complexity of the most time-efficient implementation of ‘enqueue’ and ‘dequeue,
respectively, for this data structure?
(A) Θ(1), Θ(1)
(B) Θ(1), Θ(n)
(C) Θ(n), Θ(1) 1 2 N-1 n
(D) Θ(n), Θ(n)
…….
head tail
Enqueue = Beginning O(1)
Dequeue = End O (n) since it requires
GATE 2018
the address on n-1 node
A single array A[1..MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the
array. Variables top1 and top2 (top1< top 2) point to the location of the topmost element in each of the stacks. If
the space is to be used efficiently, the condition for “stack full” is
(a) (top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1)
(b) top1 + top2 = MAXSIZE
(c) (top1= MAXSIZE/2) or (top2 = MAXSIZE)
GATE 2004
(d) top1= top2 -1
A single array A[1..MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the
array. Variables top1 and top2 (top1< top 2) point to the location of the topmost element in each of the stacks. If
the space is to be used efficiently, the condition for “stack full” is
(a) (top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1)
(b) top1 + top2 = MAXSIZE
(c) (top1= MAXSIZE/2) or (top2 = MAXSIZE)
GATE 2004
(d) top1= top2 -1
top1+ top2= maxsize
top1 top2
19 21(top2)
12 13 14 15 16 17 18 20
(top1)
GATE 2010 }
q = p;
p = p->next;
_______________________________
return head;
}
(A) q = NULL; p->next = head; head = p;
(B) q->next = NULL; head = p; p->next = head; typedef struct node
{
(C) head = p; p->next = q; q->next = NULL; int value;
(D) q->next = NULL; p->next = head; head = p; struct node *next;
}Node;
Suppose we have a balanced binary search tree T holding n numbers. We are given two numbers L and H
and wish to sum up all the numbers in T that lie between L and H. Suppose there are m such numbers in T.
If the tightest upper bound on the time to compute the sum is O( na logb n + mc logd n ), the value of a + 10b
+ 100c + 1000d is _______.
GATE CSE 2008
MCQ (Single Correct Answer)
+2
-0.6
The following three are known to be the preorder, inorder and postorder sequences of a binary tree. But it is not
known which is which. MBCAFHPYK KAMCBYPFH MABCKYFPH Pick the true statement from the following.
A
I and II are preorder and inorder sequences, respectively
B
I and III are preorder and postorder sequences, respectively
C
II is the inorder sequence, but nothing more can be said about the other two sequences
D
II and III are the preorder and inorder sequences, respectively
GATE CSE 2007
MCQ (Single Correct Answer)
+2
-0.6
The inorder and preorder traversal of a binary tree are d b e a f c g and a b d e c f g, respectively. The postorder
traversal of the binary tree is:
A
debfgca
B
edbgfca
C
edbfgca
D
defgbca
GATE | Gate IT 2007
When searching for the key value 60 in a binary search tree, nodes containing the key values 10, 20, 40, 50, 70 80, 90 are
traversed, not necessarily in the order given. How many different orders are possible in which these key values can occur
on the search path from the root to the node containing the value 60?
(A) 35
(B) 64
(C) 128
(D) 5040
GATE | Gate IT 2007
When searching for the key value 60 in a binary search tree, nodes containing the key values 10, 20, 40, 50, 70 80, 90 are
traversed, not necessarily in the order given. How many different orders are possible in which these key values can occur
on the search path from the root to the node containing the value 60?
(A) 35
(B) 64
(C) 128
(D) 5040
Answer: (A)
Explanation: There are two set of values, smaller than 60 and greater than 60. Smaller values 10, 20, 40 and 50 are
visited, means they are visited in order. Similarly, 90, 80 and 70 are visited in order.
= 7!/(4!3!)
= 35
Gate CS 2012
The height of a tree is defined as the number of edges on the longest path in the tree. The function shown in the
pseudocode below is invoked as height (root) to compute the height of a binary tree rooted at the tree pointer
root.
The appropriate expression for the two boxes B1 and B2 are
(A) B1 : (1 + height(n->right)), B2 : (1 + max(h1,h2))
(B) B1 : (height(n->right)), B2 : (1 + max(h1,h2))
(C) B1 : height(n->right), B2 : max(h1,h2)
(D) B1 : (1 + height(n->right)), B2 : max(h1,h2)
Gate CS 2012
The height of a tree is defined as the number of edges on the longest path in the tree. The function shown in the
pseudocode below is invoked as height (root) to compute the height of a binary tree rooted at the tree pointer
root.
The appropriate expression for the two boxes B1 and B2 are
(A) B1 : (1 + height(n->right)), B2 : (1 + max(h1,h2))
(B) B1 : (height(n->right)), B2 : (1 + max(h1,h2))
(C) B1 : height(n->right), B2 : max(h1,h2)
(D) B1 : (1 + height(n->right)), B2 : max(h1,h2)
Answer: (A)
A Binary Search Tree (BST) stores values in the range 37 to 573. Consider the following sequence of keys.
A Binary Search Tree (BST) stores values in the range 37 to 573. Consider the following sequence of keys.
Answer: (C)
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.
[This question was originally a Fill-in-the-Blanks question]
(A) 2
(B) 4
(C) 64
(D) 32
GATE-CS-2016
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.
[This question was originally a Fill-in-the-Blanks question]
(A) 2
(B) 4 So at 1st level, we either can choose 1 or 7(2 choices)
A binary tree with n > 1 nodes has n1, n2 and n3 nodes of degree one, two and three respectively. The degree of a node
is defined as the number of its neighbors.
Starting with the above tree, while there remains a node v of degree two in the tree, add an edge between the two
neighbors of v and then remove v from the tree. How many edges will remain at the end of the process?
(A) 2 * n1 – 3
(B) n2 + 2 * n1 – 2
(C) n3 – n2
(D) n2 + n1 – 2
A binary tree with n > 1 nodes has n1, n2 and n3 nodes of degree one, two and three respectively. The degree of a node
is defined as the number of its neighbors.
Starting with the above tree, while there remains a node v of degree two in the tree, add an edge between the two
neighbors of v and then remove v from the tree. How many edges will remain at the end of the process?
(A) 2 * n1 – 3
(B) n2 + 2 * n1 – 2
(C) n3 – n2
(D) n2 + n1 – 2
Answer: (A)
Consider the following graph among the following sequences
I. a b e g h f
II. a b f e h g
III. a b f h g e
IV. a f g h b e
GATE 2003
Consider the following graph among the following sequences
I. a b e g h f
II. a b f e h g
III. a b f h g e
IV. a f g h b e
GATE 2003
In a depth-first traversal of a graph G with n vertices, k edges are marked as tree edges. The number of connected
components in G is
(A) k
(B) k + 1
(C) n – k – 1
(D) n – k GATE 2004
In a depth-first traversal of a graph G with n vertices, k edges are marked as tree edges. The number of connected
components in G is
(A) k
(B) k + 1
(C) n – k – 1
(D) n – k
Answer: (D)
Explanation: Tree edges are the edges that are part of DFS tree. If there are x tree edges in a tree, then x+1 vertices in
the tree.
The output of DFS is a forest if the graph is disconnected.
Let G be a graph with n vertices and m edges. What is the tightest upper bound on the running time on Depth First
Search of G? Assume that the graph is represented using adjacency matrix.
(A) O(n)
(B) O(m+n)
(C) O(n2)
(D) O(mn)
GATE 2014
Let G be a graph with n vertices and m edges. What is the tightest upper bound on the running time on Depth First
Search of G? Assume that the graph is represented using adjacency matrix.
(A) O(n)
(B) O(m+n)
(C) O(n2)
(D) O(mn)
GATE 2014
Consider the tree arcs of a BFS traversal from a source node W in an unweighted, connected, undirected graph.
The tree T formed by the tree arcs is a data structure for computing.
(A) the shortest path between every pair of vertices.
(B) the shortest path from W to every vertex in the graph.
GATE 2014
(C) the shortest paths from W to only those nodes that are leaves of T.
(D) the longest path in the graph
Consider the tree arcs of a BFS traversal from a source node W in an unweighted, connected, undirected graph.
The tree T formed by the tree arcs is a data structure for computing.
(A) the shortest path between every pair of vertices.
(B) the shortest path from W to every vertex in the graph.
(C) the shortest paths from W to only those nodes that are leaves of T.
(D) the longest path in the graph
Answer: (B)
BFS always produces shortest paths from source to all other vertices in an unweighted graph. The reason is simple,
in BFS, we first explore all vertices which are 1 edge away from source, then we explore all vertices which are 2
edges away from the source and so on.
The number of different topological orderings of the vertices of
the graph is
Gate IT 2008
Consider the following sequence of nodes for the undirected graph given below.
1.a b e f d g c
2.a b e f c g d
3.a d g e b c f
4.a d b c g e f
A Depth First Search (DFS) is started at node a. The nodes are listed in the order they are first visited. Which all of the
above is (are) possible output(s)?
(A) 1 and 3 only
(B) 2 and 3 only
(C) 2, 3 and 4 only
(D) 1, 2, and 3
Which of the following statement is false?
(A) A tree with n nodes has (n-1) edges.
(B) A labeled rooted binary tree can be uniquely constructed given its postorder and
preorder traversal results.
(C) A complete binary tree with n internal nodes has (n+1) leaves.
(D) The maximum number of nodes in a binary tree of height h is (2^(h+1) -1).
Gate IT 1998
Which of the following statement is false?
(A) A tree with n nodes has (n-1) edges.
(B) A labeled rooted binary tree can be uniquely constructed given its postorder and
preorder traversal results.
(C) A complete binary tree with n internal nodes has (n+1) leaves.
(D) The maximum number of nodes in a binary tree of height h is (2^(h+1) -1).
Gate IT 1998
The following numbers are inserted into an empty binary search tree in the
given order: 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search tree
(the height is the maximum distance of a leaf node from the root)?
(A) 2
(B) 3
(C) 4
(D) 6
Gate IT 2004
The following numbers are inserted into an empty binary search tree in the
given order: 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search tree
(the height is the maximum distance of a leaf node from the root)?
(A) 2
(B) 3
(C) 4
(D) 6
Answer: (B)
Gate IT 2004
The numbers 1, 2, …. n are inserted in a binary search tree in some order. In the resulting tree, the right subtree of the
root contains p nodes. The first number to be inserted in the tree must be
(A) p
(B) p + 1
(C) n – p
(D) n – p + 1
Gate IT 2005
The numbers 1, 2, …. n are inserted in a binary search tree in some order. In the resulting tree, the right subtree of the
root contains p nodes. The first number to be inserted in the tree must be
(A) p
(B) p + 1
(C) n – p
(D) n – p + 1
Answer: (C)
Gate IT 2005
A scheme for storing binary trees in an array X is as follows. Indexing of X starts at 1 instead of 0. the root is stored at
X[1]. For a node stored at X[i], the left child, if any, is stored in X[2i] and the right child, if any, in X[2i+1]. To be able to
store any binary tree on n vertices the minimum size of X should be.
(A) log2n
(B) n
(C) 2n + 1
(D) 2^n — 1
Gate IT 2006
A scheme for storing binary trees in an array X is as follows. Indexing of X starts at 1 instead of 0. the root is stored at
X[1]. For a node stored at X[i], the left child, if any, is stored in X[2i] and the right child, if any, in X[2i+1]. To be able to
store any binary tree on n vertices the minimum size of X should be.
(A) log2n
(B) n
(C) 2n + 1
(D) 2^n — 1
Answer: (D)
Gate IT 2006
The maximum number of binary trees that can be formed with three unlabeled
nodes is:
(A) 1
(B) 5
(C) 4
(D) 3
Gate IT 2007
The maximum number of binary trees that can be formed with three unlabeled
nodes is:
(A) 1
(B) 5
(C) 4
(D) 3
Answer: (B)
Gate IT 2007
Which of the following is/are correct inorder traversal sequence(s) of binary search tree(s)?
1. 3, 5, 7, 8, 15, 19, 25
2. 5, 8, 9, 12, 10, 15, 25
3. 2, 7, 10, 8, 14, 16, 20
4. 4, 6, 7, 9, 18, 20, 25
(A) 1 and 4 only
(B) 2 and 3 only
(C) 2 and 4 only
(D) 2 only
Gate IT 2015
Which of the following is/are correct inorder traversal sequence(s) of binary search tree(s)?
1. 3, 5, 7, 8, 15, 19, 25
2. 5, 8, 9, 12, 10, 15, 25
3. 2, 7, 10, 8, 14, 16, 20
4. 4, 6, 7, 9, 18, 20, 25
(A) 1 and 4 only
(B) 2 and 3 only
(C) 2 and 4 only
(D) 2 only
Gate IT 2015
What are the worst-case complexities of insertion and deletion of a key in a binary search tree?
(A) Θ(logn) for both insertion and deletion
(B) Θ(n) for both insertion and deletion
(C) Θ(n) for insertion and Θ(logn) for deletion
(D) Θ(logn) for insertion and Θ(n) for deletion
Gate IT 2015
What are the worst-case complexities of insertion and deletion of a key in a binary search tree?
(A) Θ(logn) for both insertion and deletion
(B) Θ(n) for both insertion and deletion
(C) Θ(n) for insertion and Θ(logn) for deletion
(D) Θ(logn) for insertion and Θ(n) for deletion
Answer: (B)
Explanation: The time taken by search, insert and delete on a BST is always proportional to height of BST.
Height may become O(n) in worst case.
Gate IT 2015
Consider a complete binary tree where the left and the right subtrees of the root are max-heaps. The lower
bound for the number of operations to convert the tree to a heap is
(A) Ω(logn)
(B) Ω(n)
(C) Ω(nlogn)
(D) Ω(n2)
GATE-CS-2015
Consider a complete binary tree where the left and the right subtrees of the root are max-heaps. The lower
bound for the number of operations to convert the tree to a heap is
(A) Ω(logn)
(B) Ω(n)
(C) Ω(nlogn)
(D) Ω(n2)
Answer: (A)
While inserting the elements 71, 65, 84, 69, 67, 83 in an empty binary search tree (BST) in the sequence shown, the
element in the lowest level is
(A) 65
(B) 67
(C) 69
(D) 83
GATE-CS-2015
While inserting the elements 71, 65, 84, 69, 67, 83 in an empty binary search tree (BST) in the sequence shown, the
element in the lowest level is
(A) 65
(B) 67
(C) 69
(D) 83
Answer: (B)
GATE-CS-2015
The preorder traversal of a binary search tree is 15, 10, 12, 11, 20, 18, 16, 19. Which one of the following is the
postorder traversal of the tree ?
(A) 10, 11, 12, 15, 16, 18, 19, 20
(B) 11, 12, 10, 16, 19, 18, 20, 15
(C) 20, 19, 18, 16, 15, 12, 11, 10
(D) 19, 16, 18, 20, 11, 12, 10, 15
GATE-CS-2020
The preorder traversal of a binary search tree is 15, 10, 12, 11, 20, 18, 16, 19. Which one of the following is the
postorder traversal of the tree ?
(A) 10, 11, 12, 15, 16, 18, 19, 20
(B) 11, 12, 10, 16, 19, 18, 20, 15
(C) 20, 19, 18, 16, 15, 12, 11, 10
(D) 19, 16, 18, 20, 11, 12, 10, 15
Answer: (B)
GATE-CS-2020