GATE CS Programming and Data Structures questions
Practise Programming and Data Structures questions for GATE CS. Explore official PYQs and original subject-wise quizzes, check answers and view available solutions. Free, no sign-in.
Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.
20 on this page
What is printed by the following program? #include<stdio.h> int main(int argc, char *argv[]) { char a = ‘P’; char b = ‘x’; char c = (a&b) + ‘*’; char d = (a|b) – ‘-’; char e = (a^b) + ‘+’; printf(“%c %c %c\n”, c, d, e); return 0; } encoding for relevant characters is given below …
What is printed by the following 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, 13, 14, 15, 16, 17, 18}, {19, 20, 21, 22, 23, 24, 25, 26, 27}}; int i = 0, j = 0, k = 0; for ( i = 0; i < 3; i ++) { for ( k = 0; k < 3; k++) printf(“%d”, a[i][j][k]); printf …
Consider the queues containing four elements and containing none (shown as the in the figure). The only operations allowed on these two queues are and The minimum number of operations on required to place the elements of …
Let be an array containing integers. Let be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values in an arbitrary array of elements. Which one of the following choices is correct?
A binary search tree contains distinct elements. What is the time complexity of picking an element in that is smaller than the maximum element in ?
Consider the following sequence of operations on an empty stack.Consider the following sequence of operations on an empty queue. …
Consider the following program. #include <stdio.h> int main() { int i, j, count; count=0; i=0; for (j=-3; j<=3; j++) { if (( j >= 0) && (i++)) count = count + j; } count = count +i; printf("%d", count); return 0; } Which one of the following options is correct?
An in a connected graph is a vertex such that removing the vertex and its incident edges disconnects the graph into two or more connected components. Let be a tree obtained by doing in a connected undirected graph . Which of the following options is/are correct?
Let be a binary min-heap consisting of elements implemented as an array. What is the worst case time complexity of an optimal algorithm to find the maximum element in ?
Consider the following 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][j] = 10 * i + j; } } printf(“%d”, *(arr[1]+9)); return 0; } What is the output of the above program?
Consider a complete binary tree with nodes. Let denote the set of first elements obtained by performing Breadth-First Search starting from the root. Let denote the set of first elements obtained by performing Depth-First Search starting from the root. The value of is …
Consider the following program: #include <stdio.h> #include <stdlib.h> 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 …
The preorder traversal of a binary search tree is . Which one of the following is the postorder traversal of the tree?
What is the worst case time complexity of inserting elements into an AVL-tree with elements initially?
What is the worst case time complexity of inserting elements into an empty linked list, if the linked list needs to be maintained in sorted order?
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, 14, 15}, {16, 17,18, 19, 20}}; printf(“%d\n”, *(*(a+**a+2)+3)); return(0); } The output of the program is _______.
In a balanced binary search tree with elements, what is the worst case time complexity of reporting all elements in range ? Assume that the number of reported elements is .
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= 0; if (n>0) { i = i+ fun1 (n) ; fun2(n-1) ; } return (i); } The return value of is _________
Consider the array representation of a binary min-heap containing elements. The minimum number of comparisons required to find the maximum in the heap is ___________.
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",x); return 0; } The value printed by the program is ______________.
