Consider the following stack implemented using stack. SIZE 11 struct STACK {…
2023
Consider the following stack implemented using stack.
SIZE 11
struct STACK
{
int arr[SIZE];
int top=-1;
}
What would be the maximum value of the top that does not cause the overflow of the stack?
- A.
8
- B.
9
- C.
11
- D.
10
Attempted by 468 students.
Show answer & explanation
Correct answer: D
Answer: d
Explanation: The answer is 10. The maximum size of the array is 11; therefore, we can insert 11 elements in the stack. The top value is initialized by -1, and on every insertion, the top value gets incremented.