wiz-icon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

The following sequence of operations is performed one 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, 20
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is A 20, 20, 10, 10, 20

Stack:-

A stack is an abstract data type that serves as a collection of elements, with two principal operations: push, which adds an element to the collection, and pop, which removes the most recently added element that was not yet removed.

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.


941082_920263_ans_de3ff0f29e664f0fbc3d0f1af695f898.PNG

flag
Suggest Corrections
thumbs-up
1
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Definition of Function
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon