Time Left - 15:00 mins

GATE CS 2022 : Data Structure-1

Attempt now to get your rank among 262 students!

Question 1

Consider the following function implemented in C:
void printxy(int x, int y)
{

  int *ptr;
  x = 0;
  ptr = &x;
  y = * ptr;
  * ptr = 1;
  printf (“%d, %d,” x, y);
}


The output of invoking printxy (1, 1) is

Question 2

The post order traversal of binary search tree is given by 2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12. The height of the tree is ________.

Question 3

Consider the following C program:

#include<stdio.h>
struct ournode{
     char x,y,z;
};

int main()
{
     struct ournode q[] = { '1', '0', 'a'+2};
     struct ournode *p = q;
     printf("%c, %c", *((char*)q+1), *((char*)q+2));

}
The output of this program is :

Question 4

Consider generating Binary Search trees using a given set of numbers in the following order. Which of the following sequence of numbers will result in a tree that is strictly binary tree, i.e., every node has either two children or no children?

Question 5

Let T be a binary search tree with 14 nodes and 60 as the external path length. Then the internal path length will be

Question 6

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.
  • 262 attempts
  • 0 upvotes
  • 1 comment
Oct 7GATE & PSU CS