Computer Science and Information Technology
GATE CSE Programming and Data Structures PYQs
Build your understanding with focused practice from past exam papers.
How to practice Programming and Data Structures
Separate the algorithm, its assumptions and the cost model. Practise tracing before estimating asymptotic complexity.
Attempt a question, record the concept and assumptions, then check the available answer. Rework mistakes after revising the relevant concepts. Topic tags can overlap; review the question context.
Questions 1–10 of 106. Imported answers require independent review unless marked reviewed.
Question 12
Open questionCS2MCQ1 markNeeds review
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?
Your answerChoose one option.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 17
Open questionCS2MCQ1 markNeeds review
In C runtime environment, which one of the following is stored in heap?
Your answerChoose one option.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 19
Open questionCS2MCQ1 markNeeds review
Consider the following three ANSI-C programs, P1, P2, and P3.
P1:
#include <stdio.h>
int a=5;
int main(){
int a=7;
return(0);
}
P2:
#include <stdio.h>
int main(){
int a=5;
int a=7;
return(0);
}
P3:
#include <stdio.h>
int main(){
int a=5;
float a=7;
return(0);
}
Which one of the following statements is true?
Your answerChoose one option.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 23
Open questionCSMSQ1 markNeeds review
Let
be an odd number greater than 100. Consider a binary min heap with
elements stored in an array
whose index starts from 1.Which of the following indices of
do/does NOT correspond to a leaf node of the min heap?Your answerSelect all correct options. You can choose more than one.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 30
Open questionCS2NAT1 markNeeds review
The keys 5, 28, 19, 15, 26, 33, 12, 17, 10 are inserted into a hash table using the hash function
. The collisions are resolved by chaining. After all the keys are inserted, the length of the longest chain is __________. (answer in integer)Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 33
Open questionCSNAT1 markNeeds review
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)
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 34
Open questionCSNAT1 markNeeds review
Consider the following program in C:
#include <stdio.h>
void func(int i, int j) {
if(i < j) {
int i = 0;
while (i < 10) {
j += 2;
i++;
}
printf("%d", i);
}
}
int main() {
int i = 9, j = 10;
func(i, j);
return 0;
}
The output of the program is ________. (answer in integer)
Note: Assume that the program compiles and runs successfully.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 39
Open questionCSMCQ2 marksNeeds review
Consider the following code snippet in C language that computes the number of nodes in a non-empty singly linked list pointed to by the pointer variable head.
struct node{
int elt;
struct node *next;
};
int getListSize (struct node *head)
{
if( E1 ) return 1;
return E2;
}
Which one of the following options gives the correct replacements for the expressions E1 and E2?
Your answerChoose one option.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 40
Open questionCSMCQ2 marksNeeds review
Let
be the set of all integers from 1 to 15. Consider any order of insertion of the elements of
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?
Your answerChoose one option.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerQuestion 49
Open questionCS2MSQ2 marksNeeds review
Consider a binary search tree (BST) with
leaf nodes (
). Given any node
, the key present in the node is denoted as
. All the keys present in the given BST are distinct. The keys belong to the set of real numbers.For a node
, let
denote the node that is its inorder successor. If a node
does not have an inorder successor, then
is
. As there are no duplicates, if
is not
, then
.Corresponding to every leaf node
that has a non-NULL
, a new key
with the following property is to be inserted into the BST.
Let
represent the list of all such new keys to be inserted into the BST.Which of the following statements is/are true?
Your answerSelect all correct options. You can choose more than one.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer