Time Left - 30:00 mins

GATE 2019 -National Champion Test : (Programming & DS) (App update required to attempt this test)

Attempt now to get your rank among 847 students!

Question 1

Consider a program which stores the frequency of marks of student in a particular subject say Mathematics. The marks is in the range [0...100] and there are around 500 students. But there is one condition we only want to record frequency if the student has passed in the exam, the passing marks being 40. What is the best way to store the frequency of marks above 40?

Question 2

Consider a max heap. A heap is an almost complete binary tree and a max heap is almost complete binary tree with parent node greater than its children nodes. Consider the following keys are first inserted into an almost complete binary tree and then max heapify function is executed on it to convert it into max heap.

30, 16, 18, 35, 50, 10, 20, 23, 15

Find the number of swaps done to convert the almost complete binary tree into max heap _________.

Question 3

Consider the following Binary search tree with the following traversals
Inorder: A, M, N, O, P, Q, R, S, T, X, Z
Preorder: Q, P, A, M, N, O, X, S, R, T, Z
Find the number of elements in the 4th, 5th and 6th level respectively. Assume root is at level 1.

Question 4

Consider the following traversals of binary search tree:
Post-order: 1, 3, 5, 4, 2, 6, 9, 11, 13, 12, 10, 8, 7
Inorder : 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13  
Find the number of nodes in the last level of binary search tree? (Assume root is at first level)

Question 5

Which of the following declarations represents an array of N pointers to functions, returning pointers to functions and returning pointer to character?

Question 6

Consider the following program.
variable l;
procedure k1(var l)
begin
printf(-- l);
end
procedure K2(var m)
begin
K1(m);
End
Begin
l=6;
K2(l);
print(l);
l = l +2;
K1(l);
end
If static scoping is used, which of the following is correct output for the above program?

Question 7

Consider the following function.
int fun (int n)

ifreturn (n% 10);
else return fun

What is the return value of fun(9874)?

Question 8

Consider the following C fragment :
Void F (int n)
{
if(n<=1)
Print(1);
else
{
F(n/2);
F(n/4);
}
}
Find how many times 1 is printed by the above code if F(16) is called ?

Question 9

Given finite alphabet S={A,B,C} and stack S of size 100. There are only three stack operations we can perform as mentioned below.
push (A):push the letter A from the alphabet on to the stack
emit(): output the top letter form the stack.
pop() pop the top letter from the stack.
Stack is initially empty and we do not perform pop() on empty stack. Assume only emit() can print output and stack may or may not be empty finally. What is the minimum number of stack operations to get “ A B C A C B A” as output.

Question 10

What is the number of labelled Binary trees possible with ‘3’ nodes.

Question 11

Consider the following recursive C function :

void take (int n)

{

if(n<0)

return ;

take(n-1);

take(n-2);

take(n-3);

Printf("%d",n);

}

If take(6) function is being called in main() then how many times will the take() function be invoked before returning to the main() _____.

Question 12

Consider the following C program.

The output of the program is ______.
  • 847 attempts
  • 1 upvote
  • 14 comments
Jan 4GATE & PSU CS