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
In a binary tree with nodes, every node has an odd number of descendants. Every node is considered to be its own descendant. What is the number of nodes in the tree that have exactly one child?
Consider a binary max-heap implemented using an array. Which one of the following array represents a binary max-heap?
Consider a binary max-heap implemented using an array. What is the content of the array after two delete operations on
What is the maximum height of any AVL-tree with nodes? Assume that the height of a tree with a single node is .
The keys and are inserted into an initially empty hash table of length using open addressing with hash function and linear probing. What is the resultant hash table?
The following C function takes a single-linked list of integers as a parameter and rearranges the elements of the list. The function is called with the list containing the integers in the given order. What will be the contents of the list after function completes execution? struct node { int value; struct node *next; }; void …
Choose the correct option to fill and so that the program below prints an input string in reverse order. Assume that the input string is terminated by a new line character. void reverse(void) { int c; if(?1) reverse(); ?2 } main() { printf("Enter text"); printf("\n"); reverse(); printf("\n"); }
What is printed by the following C program? int f(int x, int *py, int **ppz) { int y, z; **ppz += 1; z = **ppz; // corrected z = *ppz; to z = **ppz; *py += 2; y = *py; x += 3; return x+y+z; } void main() { int c, *b, **a; c = 4; b = &c; a = &b; printf("%d", f(c, b, a)); }
You are given the postorder traversal, , of a binary search tree on the elements . You have to determine the unique binary search tree that has as its postorder traversal. What is the time complexity of the most efficient algorithm for doing this?
Which combination of the integer variables and makes the variable get the value in the following expression?
Consider the process of inserting an element into a , where the is represented by an array. Suppose we perform a binary search on the path from the new leaf to the root to find the position for the newly inserted element, the number of comparisons performed is:
Consider the following C program segment where represents a node in a binary tree: struct CellNode { struct CellNode *leftChild; int element; struct CellNode *rightChild; }; int Getvalue (struct CellNode *ptr) { int value = 0; if (ptr != NULL) { if ((ptr->leftChild == NULL) && (ptr->rightChild == NULL)) value = 1; else value …
A complete tree is a tree in which each node has children or no children. Let be the number of internal nodes and be the number of leaves in a complete tree. If and , what is the value of ?
Consider the following C function: int f(int n) { static int r = 0; if (n <= 0) return 1; if (n > 3) { r = n; return f(n-2) + 2; } return f(n-1) + r; } What is the value of ?
Consider a hash table of size seven, with starting index zero, and a hash function . Assuming the hash table is initially empty, which of the following is the contents of the table when the sequence is inserted into the table using closed hashing? Note that − denotes an empty location in the table.
The inorder and preorder traversal of a binary tree are and , respectively The postorder traversal of the binary tree is:
The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes in a binary tree of height is:
The maximum number of binary trees that can be formed with three unlabeled nodes is:
Statement for Linked Answer Questions 76 & 77: A -ary max heap is like a binary max heap, but instead of children, nodes have children. A -ary heap can be represented by an array as follows: The root is stored in the first location, , nodes in the next level, from left to right, is stored from to . The nodes …
Statement for Linked Answer Questions 76 & 77: A -ary max heap is like a binary max heap, but instead of children, nodes have children. A -ary heap can be represented by an array as follows: The root is stored in the first location, , nodes in the next level, from left to right, is stored from to . The nodes …
