Stack Basics: 22 MCQs

All 22 multiple-choice questions from this kit, free and with no sign-up.

Warm-up · 13 questions

Q1. What is the fundamental principle followed by a stack data structure?

Beginner
A Priority-based ordering
B First In, First Out (FIFO)
C Last In, First Out (LIFO)
D Random Access

Answers and explanations are in the Veda app.

Q2. In an array-based stack, which end is used as the top of the stack?

Beginner
A The first index (0)
B The middle index
C Any index, depending on the push order
D The last used index (top)

Answers and explanations are in the Veda app.

Q3. What does the 'top' variable in an array-based stack represent?

Beginner
A The index of the last element pushed
B The address of the stack in memory
C The total capacity of the stack
D The number of elements in the stack

Answers and explanations are in the Veda app.

Q4. What is the time complexity of the push operation in an array-based stack (without resizing)?

Beginner
A O(log n)
B O(n^2)
C O(n)
D O(1)

Answers and explanations are in the Veda app.

Q5. What condition indicates that an array-based stack is empty?

Beginner
A top == -1
B top == capacity
C top == capacity - 1
D top == 0

Answers and explanations are in the Veda app.

Q6. In an array-based stack, what does the pop operation do?

Beginner
A Removes the element at the bottom
B Increments top and adds a new element
C Returns the top element without removing it
D Removes the element at the top and decrements top

Answers and explanations are in the Veda app.

Q7. Which operation returns the top element without removing it?

Beginner
A push
B isEmpty
C pop
D peek (or top)

Answers and explanations are in the Veda app.

Q8. What is the time complexity of the peek operation in an array-based stack?

Beginner
A O(n^2)
B O(1)
C O(log n)
D O(n)

Answers and explanations are in the Veda app.

Q9. In an array-based stack, what is the initial value of the top pointer?

Beginner
A 1
B capacity - 1
C 0
D -1

Answers and explanations are in the Veda app.

Q10. In an array-based stack, the pop operation removes the element at the top of the stack.

Beginner
A True
B False

Answers and explanations are in the Veda app.

Q11. The peek operation in a stack removes the top element from the stack.

Beginner
A True
B False

Answers and explanations are in the Veda app.

Q12. In an array-based stack, what is the sequence of steps to perform a push operation? Include the overflow check.

Beginner

Answers and explanations are in the Veda app.

Q13. Describe a real-world application of a stack and explain how the LIFO principle is used in that application.

Beginner

Answers and explanations are in the Veda app.

Building up · 8 questions

Q14. What happens if you try to push onto a full array-based stack?

Intermediate
A The stack automatically resizes
B The oldest element is removed
C The element is added at index 0
D An overflow condition occurs

Answers and explanations are in the Veda app.

Q15. Which of the following is a common limitation of a fixed-size array-based stack?

Intermediate
A It cannot handle dynamic resizing
B It requires O(n) time for push
C It does not support LIFO order
D It uses more memory than a linked-list stack

Answers and explanations are in the Veda app.

Q16. What is the result of the expression: push(5), push(10), pop(), peek()?

Intermediate
A null
B 5
C 10
D Error

Answers and explanations are in the Veda app.

Q17. Which of the following applications uses a stack?

Intermediate
A Sorting a list of numbers
B Maintaining a queue of print jobs
C Undo operation in text editors
D CPU scheduling

Answers and explanations are in the Veda app.

Q18. What is the main advantage of an array-based stack over a linked-list stack?

Intermediate
A No need for a top pointer
B Unlimited size
C Better cache locality and faster access
D Simpler to implement dynamic resizing

Answers and explanations are in the Veda app.

Q19. Given an array-based stack with capacity 5, initially empty. Perform the following operations and show the final state of the stack (elements from bottom to top) and the value of `top`: push(3), push(7), pop(), push(9), push(2), pop(), peek().

Intermediate

Answers and explanations are in the Veda app.

Q20. Explain why the time complexity of all stack operations (push, pop, peek, isEmpty) is O(1) in an array-based implementation.

Intermediate

Answers and explanations are in the Veda app.

Q21. What are the consequences of not checking for stack overflow before a push and stack underflow before a pop in an array-based stack? Provide a specific example of each.

Intermediate

Answers and explanations are in the Veda app.

Topper level · 1 questions

Q22. Analyze the trade-offs between an array-based stack and a linked-list stack in terms of memory usage, performance, and flexibility. Under what conditions would you prefer the array-based version?

Advanced

Answers and explanations are in the Veda app.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free to start, in more than 40 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Paper Solver

Get Veda free See what students get

Free to start · Android app and web · More than 40 languages