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
Let be the number of different binary search trees on distinct elements. Then , where is
Assume the following C variable declaration: int *A[10], B[10][10]; Of the following expressions: which will not give compile-time errors if used as left hand sides of assignment statements in a C program?
The C language is:
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?
The number of leaf nodes in a rooted tree of n nodes, with each node having or children is:
Consider the following declaration of a two-dimensional array in C: char ; Assuming that the main memory is byte-addressable and that the array is stored starting from memory address , the address of is:
The results returned by function under value-result and reference parameter passing conventions
In the C language:
In the worst case, the number of comparisons needed to search a single linked list of length for a given element is
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?
Consider the following three C functions: int *g(void) { int x = 10; return (&x); } int *g(void) { int *px; *px = 10; return px; } 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?
What is printed by the print statements in the program 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 }
What is the minimum number of stacks of size required to implement a queue of size ?
Consider any array representation of an element binary heap where the elements are stored from index to index of the array. For the element stored at index of the array , the index of the parent is
The value of 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:
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?
Aliasing in the context of programming languages refers to
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 bytes, bytes and bytes, respectively. The memory requirement for variable , ignoring alignment consideration, is:
Consider the following nested representation of binary trees: indicates and are the left and right subtrees, respectively, of node . Note that and may be , or further nested. Which of the following represents a valid binary tree?
The most appropriate matching for the following pairs …
