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
Consider the following C program #include<stdio.h> int main() { static int a[] = {10, 20, 30, 40, 50}; static int *p[] = {a, a+3, a+4, a+1, a+2}; int **ptr = p; ptr++; printf("%d%d", ptr-p, **ptr); } The output of the program is _______.
Consider a binary tree T that has leaf nodes. Then the number of nodes in T that have exactly two children are ______.
Consider the following array of elements. The minimum number of interchanges needed to convert it into a max-heap is
Given that hash table with slots that stores elements, the load factor for is _________.
While inserting the elements in an empty binary search tree (BST) in the sequence shown, the element in the lowest level is
The result evaluating the postfix expression is
Consider the following C program segment. # include <stdio.h> int main() { char s1[7] = "1234", *p; p = s1 + 2; *p = '0'; printf("%s", s1); } What will be printed by the program?
Consider a hash table with slots. The hash function is . The collisions are resolved by chaining. The following keys are inserted in the order: . The maximum, minimum, and average chain lengths in the hash table, respectively, are
Consider a rooted n node binary tree represented using pointers. The best upper bound on the time required to determine the number of subtrees having exactly nodes is . Then the value of is __________.
Consider the following program in C language: #include <stdio.h> main() { int i; int*pi = &i; scanf("%d",pi); printf("%d\n", i+5); } Which one of the following statements is TRUE?
Let be a directed graph where is the set of vertices and the set of edges. Then which one of the following graphs has the same strongly connected components as ?
Consider the C function given below. int f(int j) { static int i = 50; int k; if (i == j) { printf("something"); k = f(i); return 0; } else return 0; } Which one of the following is TRUE?
Suppose a stack implementation supports an instruction , which reverses the order of elements on the stack, in addition to the and instructions. Which one of the following statements is (with respect to this modified stack)?
Consider the following function. double f(double x){ if( abs(x*x - 3) < 0.01) return x; else return f(x/2 + 1.5/x); } Give a value (to decimals) such that will return :_____.
A priority queue is implemented as a Max-Heap. Initially, it has elements. The level-order traversal of the heap is: . Two new elements and are inserted into the heap in that order. The level-order traversal of the heap after the insertion of the elements is:
Suppose and are unsigned int variables in a C program. We wish to set to . If is large, which one of the following statements is most likely to set correctly?
Consider the C function given below. Assume that the array contains elements, sorted in ascending order. int ProcessArray(int *listA, int x, int n) { int i, j, k; i = 0; j = n-1; do { k = (i+j)/2; if (x <= listA[k]) j = k-1; if (listA[k] <= x) i = k+1; } while (i <= j); if (listA[k] == x) return(k); else return -1; } Which …
Consider the pseudocode given below. The function takes as argument a pointer to the root of an arbitrary tree represented by the representation. Each node of the tree is of type . typedef struct treeNode* treeptr; struct treeNode { treeptr leftMostChild, rightSibling; }; int DoSomething (treeptr …
Consider a hash table with slots. Collisions are resolved using chaining. Assuming simple uniform hashing, what is the probability that the first slots are unfilled after the first insertions?
Suppose we have a balanced binary search tree holding numbers. We are given two numbers and and wish to sum up all the numbers in that lie between and . Suppose there are such numbers in . If the tightest upper bound on the time to compute the sum is , the value of …
