Consider a stack S is implemented using an array of size SIZE, which has a top pointing to the element inserted in the last to the stack. A function push is implemented and pop as well to insert and to take out elements from the stack. We need to check the condition whether the stack is full or not and empty or not while doing push and pop operations respectively.

Which among the following are the code to check the overflow and underflow conditions?

top == SIZE-1 and top == -1
top == SIZE and top == -1
top == -1 and top == SIZE-1
top == 0 and top == SIZE-1
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
State true or false:

Implementing a push operation on stack using linked list is more time efficient than that of implementation using an array: ______

True
False
None
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Consider the following pseudocode that uses a stack

declare a stack of characters

while ( there are more characters in the word to read )

{

read a character

push the character on the stack

}

while ( the stack is not empty )

{

pop a character off the stack

write the character to the screen

}

What is output for input “gate2020”?

gate2020gate2020
0202etag
gate2020
0202etag0202etag
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
A queue is a data structure where you do all insertions and deletions at:
rear and rear
Rear and front
Front and front
front and rear
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
6 elements are enqueued into the queue a, b, c, d, e, f. Then 2 elements from it are dequeued & pushed into the stack. Then one element is popped & enqueued back to queue. This process of 2 dequeue & 2 pushes & 1 pop & 1 enqueue is called as P1. If we execute P1, 3 times on the given queue & stack, then the element at the top of stack is ?
b
c
d
e
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66

If the characters ‘z’, ‘y’, ‘x’, ‘w’ are placed in a queue (in the given order), and then removed one at a time, What will be the order after they are removed?

wxyz

zyxw

xyzw

wxyz

Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.33
Postfix equivalent of + a * - * b c * / d Λ e f g h
abc*def^/g*-h*+
abc*def/^g*-h*+
abcd*ef^/g*-h*+
abc*def^/g**-h+
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
What will be the prefix equivalent of

A + B * ( C ^ D - E)

Note: Precedence of ^(here, exponential operator) is same as that of *,/,% operators.

^-CDE+*AB
*A+B-^CDE
-^CDE+*B
+A*B-^CDE
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
What will be the infix equivalence of

* - A / B C - / A K L

((A/K)-L)*(A-(B/C))
(A-(B/C))*((A/K)-L)
(A-(A/K))*((B/C)-L)
((B/C)-L)*(A-(A/K))
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
Consider the following C code:

#include <stdio.h>

void towerOfHanoi(int n, char from_rod, char to_rod, char aux_rod)

{

if (n == 1)

{

printf("\n Move disk 1 from rod %c to rod %c", from_rod, to_rod);

return;

}

towerOfHanoi(n-1, from_rod, aux_rod, to_rod);

printf("\n Move disk %d from rod %c to rod %c", n, from_rod, to_rod);

towerOfHanoi(n-1, aux_rod, to_rod, from_rod);

}

int main()

{

int n = 5; // Number of disks

towerOfHanoi(n, 'A', 'C', 'B'); // A, B and C are names of rods

return 0;

}


The optimal time of the Tower of Hanoi problem with n discs is

Note: Using recurrence method

T(n) = 2T(n – 2) + 2
T(n) = 2T(n – 1) + n
T(n) = 2T(n/2) + 1
T(n) = 2T(n – 1) + 1
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
The movement needed for 6 disks in Tower of Hanoi problem is?____
63
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.00
Consider the following C code:

#include <stdio.h>

void towerOfHanoi(int n, char from_rod, char to_rod, char aux_rod)

{

if (n == 0)

{

printf("\n Move disk 1 from rod %c to rod %c", from_rod, to_rod);

return 0;

}

towerOfHanoi(n-1, from_rod, aux_rod, to_rod);

printf("\n Move disk %d from rod %c to rod %c", n, from_rod, to_rod);

towerOfHanoi(n-1, aux_rod, to_rod, from_rod);

}

int main()

{

int n = 5; // Number of disks

towerOfHanoi(n, 'A', 'C', 'B'); // A, B and C are names of rods

return 0;

}

The total number of function calls made, in a tower of hanoi problem, when n=5 is__?

63
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.00
What is postfix equivalent of

10 + 3 * 5 / (16 - 4)

10 5 3 * 16 4 - / +
10 3 5 * 16 4 / - +
10 3 5 * 16 4 - / +
10 3 5 16 * 4 - / +
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.66
What is answer of 17 10 + 3 * 9 /
9
Difficulty Level: 1
Positive Marks: 1.00
Negative Marks: 0.00
What is the value of following postfix expression

6 2 3 + - 3 8 2 / + * 2 ↑ 3 +

where ↑ is ‘to the power/exponential operator

52
Difficulty Level: 1
Positive Marks: 2.00
Negative Marks: 0.00