100+Stack using Array Questions and Answers

Try to practice these array questions regularly in order to get used to it. Doing so, the concept of Array operation will become second nature to you and you will excel in multiple competitive exams like BCA, MCA, GATE, GRE, IES, PSC, UGC NET, DOEACC Exams etc. You should try to solve these questions yourself before moving through the answers.

Stack using Array Questions and Answers

1. Which of the following real world scenarios would you associate with a stack data structure?

a) piling up of chairs one above the other

b) people standing in a line to be serviced at a counter

c) offer services based on the priority of the customer

d) tatkal Ticket Booking in IRCTC

Answer: piling up of chairs one above the other

2. What does ‘stack underflow’ refer to?

a) accessing item from an undefined stack

b) adding items to a full stack

c) removing items from an empty stack

d) index out of bounds exception

Answer: removing items from an empty stack

3. What is the time complexity of pop() operation when the stack is implemented using an array?

a) O(1)

b) O(n)

c) O(logn)

d) O(nlogn)

Answer: O(1)

4. Which of the following array position will be occupied by a new element being pushed for a stack of size N elements (capacity of stack > N)?

a) S[N-1]

b) S[N]

c) S[1]

d) S[0]

Answer: S[N]

5. What happens when you pop from an empty stack while implementing using the Stack ADT in Java?

a) Undefined error

b) Compiler displays a warning

c) EmptyStackException is thrown

d) NoStackException is thrown

Answer: EmptyStackException is thrown

6. Array implementation of Stack is not dynamic, which of the following statements supports this argument?

a) space allocation for array is fixed and cannot be changed during run-time

b) user unable to give the input for stack operations

c) a runtime exception halts execution

d) improper program compilation

Answer: space allocation for array is fixed and cannot be changed during run-time

7. Which of the following array element will return the top-of-the-stack-element for a stack of size N elements (capacity of stack > N)?

a) S[N-1]

b) S[N]

c) S[N-2]

d) S[N+1]

Answer: S[N-1]

More Questions on Abstract Data Types (Data Structure)

100+ Array and Array Operations MCQs and Answers
100+ Stack Operations MCQs and Answers
100+ Queue Operations MCQs and Answers
100+ Singly Linked Lists MCQs and Answers
100+ Linked Lists Operations MCQs and Answers
100+ Doubly Linked Lists MCQs and Answers
100+ Circular Linked Lists MCQs and Answers
100+ Stack using Array MCQs and Answers
100+ Stack using Linked List MCQs and Answers
100+ Queue using Array MCQs and Answers
100+ Queue using Linked List MCQs and Answers
100+ Priority Queue MCQs and Answers
100+ Double Ended Queue MCQs and Answers
100+ Queue using Stacks MCQs and Answers
100+ Stack using Queues MCQs and Answers