CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

The following sequence of the operations is performed on a stack PUSH(10), PUSH(20), POP, PUSH(10), PUSH(20), POP, POP, POP, PUSH(20), POP the sequence of values popped out is

A
20,10,20,10,20
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
20,20,10,10,20
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
C
10,20,20,10,20
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
20,20,10,20,10
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is B 20,20,10,10,20

The following sequence of the operations is performed on a stack PUSH(10), PUSH(20), POP, PUSH(10), PUSH(20), POP, POP, POP, PUSH(20), POP the sequence of values popped out is 20,20,10,10,20.

Stack is collection of elements, that follows the LIFO order. LIFO stands for last In first out, which means element which is inserted most recently will be removed first.

A stack has a restriction that insertion and deletion of element can only be done from only one end of stack and we call that position as top. The element at top position is called top element. Insertion of element is called push and deletion is called pop.


flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Universal Set
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon