stack in data structure: 12 flashcards

All 12 flashcards from this kit, free and with no sign-up.

1. What does LIFO stand for and what does it mean in the context of a stack?

Show the answer

LIFO stands for Last In, First Out. It means the last element added to the stack is the first one to be removed.

2. What are the three primary operations of a stack?

Show the answer

Push (add to top), Pop (remove from top), and Peek (view top element without removing it).

3. What is a stack overflow?

Show the answer

A stack overflow occurs when a stack exceeds its allocated memory, often caused by infinite recursion or deeply nested function calls.

4. What is a stack underflow?

Show the answer

A stack underflow occurs when trying to pop from an empty stack.

5. What is the time complexity of push, pop, and peek operations in a well-implemented stack?

Show the answer

O(1) — constant time.

6. What is the call stack?

Show the answer

The call stack is a hardware/software stack that manages function calls, local variables, and return addresses in programming languages.

7. How does a stack help implement undo functionality?

Show the answer

Each action is pushed onto an undo stack. Pressing undo pops the most recent action, reversing it.

8. What are the two common ways to implement a stack?

Show the answer

Using an array (fixed size) or a linked list (dynamic size).

9. How does a stack help check balanced parentheses in code?

Show the answer

Opening brackets are pushed onto the stack; when a closing bracket is encountered, it is matched with the top of the stack. If all match and the stack is empty, the expression is balanced.

10. What is the key difference between a stack and a queue?

Show the answer

A stack follows LIFO (Last In, First Out), while a queue follows FIFO (First In, First Out).

11. Can you access an element in the middle of a stack directly?

Show the answer

No. By definition, you can only access the top element. To reach a middle element, you must pop all elements above it first.

12. How does a web browser use stacks for back/forward navigation?

Show the answer

When you visit a page, it is pushed onto a back stack. Clicking back pops it and pushes the current page onto a forward stack. Forward reverses this.

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, in 42 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Exam prep

Get Veda free See what students get

Free to start · No ads · Works in 42 languages