MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
If the sequence of operations-push (1), push (2), pop, push (1), push (2), pop, pop, pop, push (2), pop are performed on a stack, the sequence of popped out values
A
2, 2, 1, 1, 2
B
2, 2, 1, 2, 2
C
2, 1, 2, 2, 1
D
2, 1, 2, 2, 2
Explanation: 

Detailed explanation-1: -The correct answer is 2, 2, 1, 1, 2.

Detailed explanation-2: -Answer: The sequence of popped out values is : 2, 2, 1, 1, 2.

Detailed explanation-3: -The following sequence of operations is performed on a stack: push(1), push(2), pop, push(1), push(2), pop, pop, pop, push(2), pop. The values will be output in this order: 2, 1, 2, 2, 1. 2, 1, 2, 2, 2.

Detailed explanation-4: -The number that will be generated on push(5), push(8), pop, push(2), push(5), pop, push( ) will be 52 not 8552. incorrect option: (c) 255!

Detailed explanation-5: -isEmpty() isEmpty is a boolean function in stack definition which is used to check whether the stack is empty or not. It returns true if the stack is empty. Otherwise, it returns false.

There is 1 question to complete.