Time Left - 25:00 mins

GATE CSE 2020 National Champion Quiz: Programming & Data Structures (App update required to attempt this test)

Attempt now to get your rank among 688 students!

Question 1

Consider the following code segment
struct node
{
struct node *left;
int data;
struct node *right;
};
struct node*fun(struct node*P)
{
if(Prightright==NULL)
Pright=Prightleft;
else
P=fun(Pright);
return (P);
}
What does the function fun do? Assume left subtree and right subtree of Binary search tree is not NULL

Question 2

class primary
{
int I;
public int ret(int k)
{
return (I+k);
}
}
class secondary
{
public static void main(String[] args)
{
primary p=new primary();
if(p.I+p.ret(p.I)!=0)
System.out.print("Hi");
else
System.out.print("Hello");
}}
What will be output of above code ?

Question 3

Worst case time complexity to delete the root from min heap tree of n elements is ___.

Question 4

Consider the postfix expression 4 2 1 4 2 ^ × × 8 / + 3 – , let the result of evaluating the expression be x and the maximum stack size be y. Then find the value of x/y ________.

Question 5

Consider the following C program code.

What will be the output of the above code _____________?

Question 6

What is the sum of outputs printed by running the following program?
int main ( )
{
int i ;
for (i = 3; i < = 6; i++)
printf(“%d”, f1(i));
}
int f1 (int n)
{
if (n < 2) return n;
else return (f1(n –1) + f2(n – 2));
}
int f2 (int n)
{
if (n < = 1) return n;
else return (2 f1 (n – 2) + 1);
}

Question 7

Suppose depth first search is executed on the graph below starting at some unknown vertex. Assume that a recursive call to visit a vertex is made only after first checking that the vertex has not been visited earlier. Then the maximum possible recursion depth (including the initial call) is _________.

Question 8

The following function computes the maximum value contained in an integer array p[ ] of size

The missing loop condition is

Question 9

Consider the following C code which is implemented on a linked list :
Struct node *Insert_x_and_y(Struct node *S , int X , int Y)
{
Struct node *P , *Q , *S1;
P = (Struct node*)malloc(sizeof(Struct node));
P->data = x;
P->next = NULL;
If(S==null)
return (NULL);
if(S->data==y)
{
P->next = S;
S = P;
return (S);
}
else
{
S1=S;
while(S1->data!=y && S1->next!=NULL)
{
Q=S1;
S1=S1->next;
}
if(S1->data==y)
{
Q->next = P;
P->next = S;
}
else
Printf("No y found")
return (S);
}
}
What does the following code does ?

Question 10

Consider the following elements in a heap {17, 9, 6, 3, 12, 2, 15, 14, 20, 13, 21}. The minimum number of exchanges to convert it into a minheap be P. Then the minimum number of elements that can be arranged in a BST of height P is

Question 11

Let G be a finite group on 84 elements. The size of a largest possible proper subgroup of G is _________.

Question 12

The porder sequence of a binary tree is 4, 2, 1, 5, 3, 6, 7
Consider the following sequences:
I. 4, 5, 2, 7, 6, 3, 1 is in postorder sequence.
II. 1, 2, 4, 3, 5, 6, 7 is in preorder sequence.
III. 4, 2, 5, 7, 6, 3, 1 is Inoder sequence.
Which of them are correct?

  • 688 attempts
  • 4 upvotes
  • 6 comments
Mar 27GATE & PSU CS