0% found this document useful (0 votes)
9 views25 pages

महा Abhyas Computer Science and Infirmation Technology Data Structure

The document contains a series of questions related to data structures, specifically focusing on arrays, stacks, queues, linked lists, binary trees, heaps, and graphs, as part of the GATE 2023 examination. Each question presents multiple-choice options regarding the time complexity of operations and traversal methods. Additionally, there are pseudo code snippets and function outputs to analyze and determine correct answers.

Uploaded by

mitesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views25 pages

महा Abhyas Computer Science and Infirmation Technology Data Structure

The document contains a series of questions related to data structures, specifically focusing on arrays, stacks, queues, linked lists, binary trees, heaps, and graphs, as part of the GATE 2023 examination. Each question presents multiple-choice options regarding the time complexity of operations and traversal methods. Additionally, there are pseudo code snippets and function outputs to analyze and determine correct answers.

Uploaded by

mitesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Type Subject Name

Data Structure

 By- Abhishek Sharma


1 Array

2 Stack ,Queue , Linked List

3 Binary Tree, Binary Search Tree

4 Heap

5 Graph
(GATE 2023)
QUESTION- 01

A SLLdel is O(1) and DLLdel is O(n)

B Both SLLdel and DLLdel are O(log(n))

C Both SLLdel and DLLdel are O(1)

D SLLdel is O(n) and DLLdel is O(1)


(GATE 2023)
QUESTION- 02

A Both Extract-Max(A) and Insert(A,key) run in O(1).

B Both Extract-Max(A) and Insert(A,key) run in O(log(n)).

C Extract-Max(A) runs in O(1) whereas Insert(A,key) runs in O(n).

D Extract-Max(A) runs in O(1) whereas Insert(A,key) runs in O(log(n)).


(GATE 2023)
QUESTION- 03

Consider the C function foo and the binary tree shown

When foo is called with a pointer to the root node


of the given binary tree, what will it print?

A 3 8 5 13 11 10 B 3 5 8 10 11 13 C 3 8 16 13 24 50 D 3 16 8 50 24 13
(GATE 2023)
QUESTION- 03
QUESTION- 04
(GATE 2023)
QUESTION-
Question 05
: NAT
Suppose the stack S support the operation of push
pop and Reverse. Reverse operation reverse the entire
content of stack. Similarly Queue support the
operation of Enqueue , dequeue and reverse( reverse
entire content of the queue. In addition to that it also
support the operation of isEmpty() for stack and
queue which returns true if stack or queue is empty.

Consider the following pseudo code


QUESTION- 05

int dosomething (){ x=pop(s);


int i,x,y; y=dequeue(Q);
for (i = 1;i<=10;i++) { return x+y;
if ( i%2 = =0) { }
reverse(s);
push(s,i);
reverse(s);
}
else {
reverse(q);
enqueue(Q,i);
reverse(q);
}
}
The return value of the function is____
QUESTION- 06
(GATE 2022)

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.


QUESTION- 07
(GATE 2022)
QUESTION- 07
(GATE 2022)
QUESTION- 08
(GATE 2022)
QUESTION- 9
(GATE 2021)

Consider the following statements.


𝑆1 : The sequence of procedure calls corresponds to a preorder
traversal of the activation tree.
𝑆2 : The sequence of procedure returns corresponds to a postorder
traversal of the activation tree.

Which one of the following options is correct?


A 𝑆1 is true and 𝑆2 is false

B 𝑆1 is false and 𝑆2 is true

C 𝑆1 is true and 𝑆2 is true

D 𝑆1 : is false and 𝑆2 is false


QUESTION- 10
(GATE 2020)
The preorder traversal of a binary search tree is 15, 10, 12, 11,
20, 18, 16, and 19. Which one of the following is the postorder
traversal of the tree?
Which one of the following options is correct?

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


QUESTION- 11
(GATE 2020)

For a C program accessing X[i] [j] [k], the following


intermediate code is generated by a compiler. Assume that the size of
an integer is 2 byte and the size of a character is 1 Byte.
t0 = i * 4096
t1 = j * 128
t2 = k * 2
t3 = t1 + t0
t4 = t3 + t2
t5 = X[t4]
Which one of the following statements about the source code for the C
program is CORRECT?
QUESTION- 11
(GATE 2020)

(A) X is declared as “int X[32][32][8]”.


(B) X is declared as “int X[4][1024][32]”.
(C) X is declared as “int X[4][32][64]”.
(D) X is declared as “char X[32][32][64]”.
QUESTION- 12
(MSQ)

Consider the following functions

void funl (int n) { void fun2 (int n) {

if (n = =0 ) return; if (n = = 0) return ;

printf (“%d” , n); printf (“%d” , n);

fun2 (n - 2); fun1(++n) ;

} }
QUESTION- 12
(GATE 2020)

Which of the following is TRUE for above function


(A) fun1(4) output is 4 2 3 1 2
(B) Computation of fun1(4) needs computation of fun1(3)
(C) fun2(4) is 4 5 3 1 2
(D) fun1(5) value will be 6 4 5 3 1 2
QUESTION- 12
(GATE 2020)

Which of the following is TRUE for above function

(A) fun1(4) output is 4 2 3 1 2

(B) Computation of fun1(4) needs computation of fun1(3)

(C) fun2(4) is 4 5 3 1 2

(D) fun1(5) value will be 6 4 5 3 1 2


QUESTION- 13

Convert the pre-fix expression to in-fix


–* + ABC* – DE + FG
(a) (A – B)*C + (D*E) – (F + G)
(b) (A + B)*C – (D – E)*(F + G)
(c) (A + B – C)*(D – E))*(F + G)
(d) (A + B)*C – (D*E) – (F + G)
QUESTION- 14

If the list contain the value 1→2→3 then what What is the output of the following function
is the Output following function.
(A)3321332
void fun (struct node *ptr){
(B)3323321332332
if (ptr){
fun (ptr -> link); (C) 33233213323321
printf ("%d", ptr ->data); (D)NULL pointer dereferencing
fun (ptr->link);
printf("%d", ptr->data);
}
return;
}
QUESTION- 14

If the list contain the value 1→2→3 then what


is the Output following function.
void fun (struct node *ptr){
if (ptr){
fun (ptr -> link);
printf ("%d", ptr ->data);
fun (ptr->link);
printf("%d", ptr->data);
}
return;
}

You might also like