Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ipiemerted as a class containing an array of items, a data member indicating the

ID: 3725882 • Letter: I

Question

ipiemerted as a class containing an array of items, a data member indicating the index of the last item put on the stack members, underFlow and overFlow. The stack items are characters and MAX ITEM is 5. In the following (top), and two Boolean data show the result of the operation on the stack. Put a T or F for true or false, respectively, in the Boolean data members. (3 point each) a. stack Push(letter), etter eter stack.lop stack top underFlow 141 11] [2 13 b. stack.Push(letter); letter letter stack top stack.top overFlow underFlow underFlow items [1] [2] [A] c. stack.Pop(leder); leter etter stack top stack.top overFlow underFlow A B [1] [1] [2] [3] [4] [2] [3] [4] d. stack.Pop(letter) letter letter stack top stack.top underFlow items

Explanation / Answer

a) Overflow = F

Underflow =F

Because maximum size of the stack is 5. top indicates the index of last item inserted which is 2. Stack is not full. So when try to insert M, it can be inserted.

b) Overflow=T

Underflow=F

Because top=4 which means there is no gap to insert element again. Because index starts from 0. When 5th element inserted to stack, top=4. Stack is full.

c) Overflow =F

Underflow = T

top = - 1 means there is no element in stack. Stack is empty. In such case there is no element to pop from stack. It is underflow.

d) Overflow = T

Underflow = F

Here it is overflow, but there is no issue here. We are not going to push element into stack. Here an element is trying to pop. top=4, which means stack is full so an element from top can be successfully poped out from stack.