COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Bottom
|
|
Top
|
|
Start
|
|
Last
|
Detailed explanation-1: -A stack is an ordered list in which all insertions and deletions are made at one end, called the top. A queue is an ordered list in which all insertions take place at one end, the rear, while all deletions take place at the other end, the front.
Detailed explanation-2: -The top function returns the topmost element of the stack. You should ensure that there are one or more elements on the stack before calling the top function. The first version of the top function returns a reference to the element of the top of the stack, allowing you to modify the value.
Detailed explanation-3: -So top=-1 will initially mean that it is in a empty state and you can say no member is being added to the stack data structure.
Detailed explanation-4: -In stack, the insertion and deletion operations are performed based on LIFO (Last In First Out) principle. In a stack, the insertion operation is performed using a function called “push” and deletion operation is performed using a function called"pop".
Detailed explanation-5: -The “top” element of the stack is the element that was last pushed and will be the first to be popped. The “bottom” element of the stack is the one that, when removed, will leave the stack empty.