Skip to content

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
Official PYQ2003Programming and Data StructuresBinary Search TreesMCQ · 1 mark
Let T(n)T(n) be the number of different binary search trees on nn distinct elements. Then T(n)=∑k=1nT(k−1)T(x)T(n) = \sum_{k=1}^{n} T(k-1)T(x), where xx is
Official PYQ2003Programming and Data StructuresProgramming in CMCQ · 1 mark
Assume the following C variable declaration: int *A[10], B[10][10]; Of the following expressions: A[2]A[2] A[2][3]A[2][3] B[1]B[1] B[2][3]B[2][3] which will not give compile-time errors if used as left hand sides of assignment statements in a C program?
Official PYQ2002Programming and Data StructuresProgramming in CMCQ · 1 mark
The C language is:
Official PYQ2002Programming and Data StructuresTreesMCQ · 1 mark
A weight-balanced tree is a binary tree in which for each node, the number of nodes in the left sub tree is at least half and at most twice the number of nodes in the right sub tree. The maximum possible height (number of nodes on the path from the root to the furthest leaf) of such a tree on n nodes is best described by which of the following?
Official PYQ2002Programming and Data StructuresTreesMCQ · 1 mark
The number of leaf nodes in a rooted tree of n nodes, with each node having 00 or 33 children is:
Official PYQ2002Programming and Data StructuresProgramming in CMCQ · 1 mark
Consider the following declaration of a two-dimensional array in C: char a[100][100]a[100][100]; Assuming that the main memory is byte-addressable and that the array is stored starting from memory address 00, the address of a[40][50]a [40][50] is:
Official PYQ2002Programming and Data StructuresProgramming in CMCQ · 1 mark
The results returned by function under value-result and reference parameter passing conventions
Official PYQ2002Programming and Data StructuresProgramming in CMCQ · 1 mark
In the C language:
Official PYQ2002Programming and Data StructuresLinked ListsMCQ · 1 mark
In the worst case, the number of comparisons needed to search a single linked list of length nn for a given element is
Official PYQ2001Programming and Data StructuresProgramming in CMCQ · 1 mark
Consider the following program Program P2 var n : int; procedure W(var x : int) begin x = x + 1; print x; end procedure D begin var n : int; n = 3; W(n); end begin \\begin P2 n=10; D; end If the language has dynamic scooping and parameters are passed by reference, what will be printed by the program?
Official PYQ2001Programming and Data StructuresProgramming in CMCQ · 1 mark
Consider the following three C functions: [P1][P1] int *g(void) { int x = 10; return (&x); } [P2][P2] int *g(void) { int *px; *px = 10; return px; } [P3][P3] int *g(void) { int *px; px = (int*) malloc (sizeof(int)); *px = 10; return px; } Which of the above three functions are likely to cause problems with pointers?
Official PYQ2001Programming and Data StructuresProgramming in CMCQ · 1 mark
What is printed by the print statements in the program P1P1 assuming call by reference parameter passing? Program P1() { x = 10; y = 3; func1(y,x,x); print x; print y; } func1(x,y,z) { y = y + 4; z = x + y + z }
Official PYQ2001Programming and Data StructuresArrays, Stacks and QueuesMCQ · 1 mark
What is the minimum number of stacks of size nn required to implement a queue of size nn?
Official PYQ2001Programming and Data StructuresBinary HeapsMCQ · 1 mark
Consider any array representation of an nn element binary heap where the elements are stored from index 11 to index nn of the array. For the element stored at index ii of the array (i≤n)(i \leq n), the index of the parent is
Official PYQ2000Programming and Data StructuresProgramming in CMCQ · 1 mark
The value of jj at the end of the execution of the following C program: int incr (int i) { static int count = 0; count = count + i; return (count); } main () { int i, j; for (i = 0; i <= 4; i++) j = incr (i); } is:
Official PYQ2000Programming and Data StructuresTreesMCQ · 1 mark
Let LASTPOST, LASTIN and LASTPRE denote the last vertex visited `in a postorder, inorder and preorder traversal respectively, of a complete binary tree. Which of the following is always true?
Official PYQ2000Programming and Data StructuresProgramming in CMCQ · 1 mark
Aliasing in the context of programming languages refers to
Official PYQ2000Programming and Data StructuresProgramming in CMCQ · 1 mark
Consider the following C declaration: struct { short x[5]; union { float y; long z; } u; )t; Assume that the objects of the type short, float and long occupy 22 bytes, 44 bytes and 88 bytes, respectively. The memory requirement for variable tt, ignoring alignment consideration, is:
Official PYQ2000Programming and Data StructuresTreesMCQ · 1 mark
Consider the following nested representation of binary trees: (X Y Z)(X \ Y \ Z) indicates YY and ZZ are the left and right subtrees, respectively, of node XX. Note that YY and ZZ may be NULLNULL, or further nested. Which of the following represents a valid binary tree?
Official PYQ2000Programming and Data StructuresProgramming in CMCQ · 1 mark
The most appropriate matching for the following pairs …