Which of the following best describes a stack data structure?
Stacks — Important Questions
SUMMARY: The chapter on Stacks in Class 12 Computer Science covers the concept, implementation, and applications of stack data structures.
KEY TOPICS: stack definition, LIFO principle, stack operations, stack implementation using arrays, stack implementation using linked lists, applications of stacks, recursion and stacks, infix to postfix conversion, evaluation of postfix expressions, stack overflow and underflow.
Which operation is used to add an element to a stack?
Check answerHide answer
Which operation is used to remove the top element of a stack?
Check answerHide answer
A stack overflow occurs when:
Check answerHide answer
Which Python data type is most commonly used to implement a stack?
Check answerHide answer
Define stack and explain its LIFO principle.
List any three real-life applications of stacks.
Differentiate between stack and queue with two points.
Write a Python function to push an element onto a stack implemented as a list.
Explain when a stack overflow and a stack underflow occur.
Write a Python program to implement a stack using a list. Include push pop peek and isEmpty operations.
Discuss any five applications of stacks in computer science.
Write a Python program using a stack to check if a given string of brackets is balanced.
Explain how the call stack works during function execution especially with recursion.
Write a Python program using a stack to reverse a string.
Differentiate between stack and queue data structures in tabular form on five features.
Assertion (A): Stack follows the LIFO principle.
Reason (R): The last element pushed is the first one popped.
Show explanationHide explanation
Assertion (A): Function calls in most languages use a stack.
Reason (R): The call stack tracks the order of function calls and returns.
Show explanationHide explanation
Assertion (A): The peek operation returns the top element without removing it.
Reason (R): It does not modify the stack.
Show explanationHide explanation
Assertion (A): Stack overflow happens when the stack reaches its maximum capacity.
Reason (R): Pushing more elements is not allowed in a fixed-size stack.
Show explanationHide explanation
Assertion (A): The undo feature in many applications uses a stack.
Reason (R): Each action is pushed and the undo command pops the last action.
Show explanationHide explanation
Statement 1: A stack has only one entry/exit point called the top.
Statement 2: All operations are performed at the top.
Show answerHide answer
Statement 1: Push and pop are the two basic stack operations.
Statement 2: Both operate on the top of the stack.
Show answerHide answer
Statement 1: Stack can be implemented using arrays or linked lists.
Statement 2: In Python list operations append() and pop() implement push and pop.
Show answerHide answer
Statement 1: Stacks are used in expression evaluation.
Statement 2: Infix to postfix conversion uses a stack.
Show answerHide answer
Statement 1: Browser back button uses a stack.
Statement 2: Each visited page is pushed; back pops the most recent one.
Show answerHide answer
-
A stack uses which principle?AFIFOBLIFOCRandom accessDPriority
-
Which operation removes the top element of a stack?ApushBpopCpeekDenqueue
-
Write the Python program using a stack to check balanced brackets.
Show answersHide answers
Trace the stack contents after each operation (push or pop).
| Operation | Stack after |
|---|---|
| push 10 | ? |
| push 20 | ? |
| push 30 | ? |
| pop | ? |
| push 40 | ? |
| pop | ? |
Trace the stack to evaluate balanced bracket check on the string '([{}])'.
| Char read | Action | Stack after |
|---|---|---|
| ( | push | [(] |
| [ | push | [(, [] |
| { | push | [(, [, {] |
| } | ? | ? |
| ] | ? | ? |
| ) | ? | ? |
Study the operations on a stack and answer:
| Operation | Effect | Time complexity |
|---|---|---|
| push(x) | Add x at top | O(1) |
| pop() | Remove top, return | O(1) |
| peek()/top() | Return top, no remove | O(1) |
| isEmpty() | Check if empty | O(1) |
| size() | Return count | O(1) |
-
Which operation returns the top element WITHOUT removing it?ApushBpopCpeekDsize
-
The time complexity of push and pop on a stack is:AO(1)BO(log n)CO(n)DO(n^2)
-
Discuss any five real-world applications of stacks.
Show answersHide answers
Study the stack push and pop visualisation and answer:
-
A stack uses which principle?AFIFOBLIFOCRandomDPriority
-
Which operation removes the top element?ApushBpopCpeekDenqueue
-
Discuss the LIFO principle with stack push pop and peek operations.
Show answersHide answers
Make a full Computer Science paper on Stacks.
Pick the question mix, set the marks, hit generate. You get a ready-to-print paper with an answer key.
Generate your paper — free