COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
TOP
|
|
BOT
|
|
POT
|
|
none of the above
|
Detailed explanation-1: -The top variable keeps track of the top of the stack and is initially set to 0 by the constructor, indicating that the 0 position of the array is the top of the stack, at least until an element is pushed onto the stack.
Detailed explanation-2: -After the function returns, the stack memory of this function is deallocated, which means all local variables become invalid. The allocation and deallocation for stack memory is automatically done. The variables allocated on the stack are called stack variables, or automatic variables.
Detailed explanation-3: -If you start at top = 0 then top is always equal to the number of elements on your stack.
Detailed explanation-4: -peek() – get the top element without removing it. isEmpty() – checks whether stack is empty or not. isFull() – checks whether stack is full or not.