COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
full
|
|
empty
|
|
half
|
|
all of above
|
Detailed explanation-1: -Push Operation : The push operation is used to insert an element into the stack. The new element is added at the topmost position of the stack. However, before inserting the value, we must first check if TOP=MAX–1, because if that is the case, then the stack is full and no more insertions can be done.
Detailed explanation-2: -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-3: -When the value of top becomes MAX – 1 after a series of insertion, it means that stack is full.
Detailed explanation-4: -It will cause a stack overflow, and how that is handled is also up to how you implemented your stack. Ideally, the stack implementation should know when it is at full capacity. When the stack is at capacity and a push is attempted, it will generally throw an exception and not attempt to add an element at all.
Detailed explanation-5: -In the pushdown stacks only two operations are allowed: push the item into the stack, and pop the item out of the stack. A stack is a limited access data structure-elements can be added and removed from the stack only at the top. push adds an item to the top of the stack, pop removes the item from the top.