Time Left - 15:00 mins

Programming & DS Rapid Quiz -3 (App update required to attempt this test)

Attempt now to get your rank among 636 students!

Question 1

Consider evaluating the following expression tree on a machine with load-store architecture in which memory can be accessed only through load and store instructions. The variables a, b, c, d and e are initially stored in memory. The binary operators used in this expression tree can be evaluated by the machine only when the operands are in registers. The instructions produce result only in a register. If no intermediate results can be stored in memory, what is the minimum number of registers needed to evaluate this expression?

Question 2

Consider the following while loop which is a part of function insert() which inserts key x, befor key y in the single linked lists.Initially temp points to first node of the lists.
While(tempdata!=y)
{
q=temp;
temp=tempnext;
}
Assume every aspect of function insert() is correct, except the while loop. What is wrong with the while loop?

Question 3

Consider the following elements :

5, 12, 3, 15, 4, 6, 10

These elements are inserted into max heap tree using two different methods. In method 1, elements are inserted one by one into heap and heap property is maintained at every step. In method 2, first these elements are stored into an almost complete binary tree and then max-heapify function is executed on it. Now find the number of elements that has different index position into two heaps generated from given two methods _________.

Question 4

In C language, values are passed using two methods i.e. call by value and call by reference. To use call by reference, we use '*' operator and access the memory of the variable passed. Now consider the following code :

F(int *a, int b)

{

if(b==1)

return *a;

else

{

*a = *a + b

return F(a,b-1);

}

}

Main()

{

int x = 4 , y = 7;

int result = F(&x,y);

Print (result);

}

What is the output _______________.

Question 5

In which order the following numbers 7,5,1,8,3 and 2, should be inserted into an an binary search  tree to get inorder and preorder traversal sequences as same-

Question 6

Consider the graph.

Which of the following is a valid topological ordering?
  • 636 attempts
  • 3 upvotes
  • 4 comments
Apr 4GATE & PSU CS