Previous GATE Questions in Programming and DS

#21
8.4k
views
2 answers
14 votes
What is printed by the following $\text{ANSI C}$ program?#include<stdio.h int main (int argc, char *argv[]) { int a[3][3][3] = {{1, 2, 3, 4, 5, 6, 7, 8, 9}, {10, 11, 12, ...
#22
11.5k
views
1 answers
20 votes
What is printed by the following $\text{ANSI C}$ program?#include<stdio.h int main(int argc, char *argv[]) { char a = ‘P’; char b = ‘x’; char c = (a&b) + ‘*’;...
#23
19.3k
views
6 answers
34 votes
Consider the queues $Q_{1}$ containing four elements and $Q_{2}$ containing none (shown as the $\textsf{Initial State}$ in the figure). The only operations allowed on the...
#24
9.2k
views
4 answers
14 votes
​​​​​Let $H$ be a binary min-heap consisting of $n$ elements implemented as an array. What is the worst case time complexity of an optimal algorithm to find the...
#25
30.7k
views
11 answers
40 votes
Consider the following $\text{ANSI C}$ program.#include <stdio.h int main() { int arr[4][5]; int i, j; for (i=0; i<4; i++) ​​​​​​{ for (j=0; j<5; j++) { arr[i...
#26
11.5k
views
3 answers
14 votes
Consider a complete binary tree with $7$ nodes. Let $A$ denote the set of first $3$ elements obtained by performing Breadth-First Search $\text{(BFS)}$ starting from the ...
#27
9.9k
views
2 answers
17 votes
Consider the following $\text{ANSI C}$ program:#include <stdio.h #include <stdlib.h struct Node{ int value; struct Node *next;}; int main( ) { struct Node *boxE, *head, *...
#28
17.3k
views
4 answers
33 votes
​​​​​Let $P$ be an array containing $n$ integers. Let $t$ be the lowest upper bound on the number of comparisons of the array elements, required to find the min...
#29
12.1k
views
3 answers
19 votes
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$?$\Theta(...
#30
8.6k
views
3 answers
10 votes
Consider the following sequence of operations on an empty stack.$$\textsf{push}(54);\textsf{push}(52);\textsf{pop}();\textsf{push}(55);\textsf{push}(62);\textsf{s}=\texts...
#31
9.4k
views
4 answers
19 votes
​​​​​Consider the following$\text{ ANSI C}$ program.#include <stdio.h int main() { int i, j, count; count=0; i=0; for (j=-3; j<=3; j++) { if (( j >= 0) && (i++)...
#32
14.3k
views
2 answers
30 votes
An $articulation$ $point$ in a connected graph is a vertex such that removing the vertex and its incident edges disconnects the graph into two or more connected component...
#33
19.2k
views
5 answers
8 votes
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?$10,11,12,15,16,18,1...
#34
14.1k
views
2 answers
27 votes
What is the worst case time complexity of inserting $n^{2}$ elements into an AVL-tree with $n$ elements initially?$\Theta (n^{4})$$\Theta (n^{2})$$\Theta (n^{2}\log n)$$\...
#35
27.1k
views
9 answers
37 votes
What is the worst case time complexity of inserting $n$ elements into an empty linked list, if the linked list needs to be maintained in sorted order?$\Theta(n)$$\Theta(n...
#36
24.0k
views
2 answers
36 votes
Consider the following C program.#include <stdio.h int main () { int a[4] [5] = {{1, 2, 3, 4, 5}, {6, 7,8, 9, 10}, {11, 12, 13, ...
#37
22.5k
views
4 answers
29 votes
In a balanced binary search tree with $n$ elements, what is the worst case time complexity of reporting all elements in range $[a,b]$? Assume that the number of reported ...
#38
23.9k
views
3 answers
38 votes
Consider the following C functions.int fun1(int n) { static int i= 0; if (n 0) { ++i; fun1(n-1); } return (i); }int fun2(int n) { static int i= ...
#39
15.4k
views
6 answers
28 votes
Consider the array representation of a binary min-heap containing $1023$ elements. The minimum number of comparisons required to find the maximum in the heap is _________...
#40
9.9k
views
4 answers
13 votes
Consider the following C program :#include<stdio.h int jumble(int x, int y){ x = 2*x+y; return x; } int main(){ int x=2, y=5; y=jumble(y,x); x=jumble(y,x); printf("%d \n"...