a
askaideAI
Log in
— CHAPTER MASTERY · CLASS 12

Stack Important Questions.

Master Stack with AI-powered practice. Our adaptive tutor identifies your gaps and provides step-by-step explanations for every topic in this chapter.

Exam-Ready Questions

Practice questions specifically designed for CBSE Class 12 Computer Science board exams. Covers all difficulty levels from basic to advanced.

Instant AI Doubts

Stuck on a tricky concept in Stack? Our AI tutor provides immediate, step-by-step explanations 24/7.

Adaptive Practice

The difficulty adjusts as you learn. Master foundations first, then move to challenging board-level problems.

Stack — Important Questions with Answers

Practice these Stack questions for Class 12 Computer Science, each with the correct answer and a step-by-step explanation. Sign up free to practice all 48+ questions with adaptive difficulty.

  1. Q1Hard

    Which of the following operations adheres to the LIFO principle?

    • A.Adding elements to the end of an array
    • B.Removing elements from the middle of a linked list
    • C.Popping the last inserted element first
    • D.Accessing elements by index in a list
    Answer: Popping the last inserted element first

    Explanation: The LIFO (Last-In-First-Out) principle is the core characteristic of a stack. When elements are added (pushed) to the stack, the last element pushed is the first one to be removed (popped). This principle is fundamental to stack operations and distinguishes it from other data structures like queues or arrays.

  2. Q2Hard

    What is the correct postfix notation for the infix expression `(A + B) * C`?

    • A.A+B*C
    • B.AB+C*
    • C.A*B+C
    • D.C*AB+
    Answer: AB+C*

    Explanation: To convert the infix expression `(A + B) * C` to postfix, we use a stack to handle operator precedence. Parentheses are resolved first, followed by operators with higher precedence. The correct postfix notation is `AB+C*`, ensuring that multiplication happens after the addition of `A` and `B`.

  3. Q3Hard

    In Python, which method is used to remove the top element from a stack implemented using a list?

    • A.remove()
    • B.pop()
    • C.delete()
    • D.clear()
    Answer: pop()

    Explanation: In Python, lists inherently support stack operations. The `pop()` method removes and returns the last element in the list, which corresponds to the top of the stack. This method adheres to the LIFO principle, making it ideal for stack operations.

  4. Q4Hard

    Which of the following is NOT a real-world application of a stack?

    • A.Browser history navigation
    • B.Undo/redo functionality in text editors
    • C.Parentheses matching in compilers
    • D.Managing a circular queue for task scheduling
    Answer: Managing a circular queue for task scheduling

    Explanation: Stacks are used in applications like undo/redo mechanisms, browser history, and parentheses matching. However, managing a circular queue for task scheduling involves FIFO (First-In-First-Out) principles, which is characteristic of queues, not stacks.

  5. Q5Hard

    What is the output of the following Python code snippet? ```python stack = [] stack.append(1) stack.append(2) stack.append(3) stack.pop() stack.pop() stack.append(4) print(stack) ```

    • A.[1, 2]
    • B.[2, 3]
    • C.[1, 4]
    • D.[3, 4]
    Answer: [1, 4]

    Explanation: The code snippet demonstrates stack operations using Python lists. Elements `2` and `3` are popped, leaving `[1]`. After pushing `4`, the stack becomes `[1, 4]`. This follows the LIFO principle, where the last pushed element is the first to be popped.

  6. Q6Hard

    Which operator has the highest precedence in the expression `A * B + C / D`?

    • A.+
    • B.* and /
    • C.-
    • D.All have equal precedence
    Answer: * and /

    Explanation: In arithmetic expressions, multiplication (`*`) and division (`/`) have higher precedence than addition (`+`) and subtraction (`-`). Both `*` and `/` are evaluated before `+`, ensuring the correct order of operations as per BODMAS rules.

  7. Q7Hard

    What is the role of a stack in handling function calls in a program?

    • A.Storing global variables
    • B.Maintaining the return addresses and local variables
    • C.Sorting data structures
    • D.Managing database connections
    Answer: Maintaining the return addresses and local variables

    Explanation: In compilers and interpreters, a stack is used to manage function calls by storing return addresses and local variables. When a function is called, its details are pushed onto the stack, and when it returns, these details are popped off, ensuring proper execution flow.

  8. Q8Hard

    What is the primary difference between a stack and a queue?

    • A.Stacks are implemented using linked lists, while queues use arrays
    • B.Stacks follow FIFO, while queues follow LIFO
    • C.Stack follows LIFO, while queue follows FIFO
    • D.Stacks and queues have no difference in their operations
    Answer: Stack follows LIFO, while queue follows FIFO

    Explanation: The primary difference lies in their access principles. Stacks adhere to the Last-In-First-Out (LIFO) principle, meaning the last element added is the first one removed. In contrast, queues follow the First-In-First-Out (FIFO) principle, where the first element added is the first one removed.

  9. Q9Hard

    Which of the following is a correct postfix expression for the infix expression `A - B / C`?

    • A.AB/C-
    • B.ABC/-
    • C.A-B/C
    • D.C/B-A
    Answer: ABC/-

    Explanation: To convert `A - B / C` to postfix, we handle operator precedence. Division (`/`) is performed before subtraction (`-`). The correct postfix notation is `ABC/-`, ensuring that division is completed before subtraction.

  10. Q10Hard

    How does a stack help in evaluating postfix expressions?

    • A.By ignoring parentheses
    • B.By using a queue instead of a stack
    • C.By reversing the expression order
    • D.By using a stack to store operands and applying operators as they are encountered
    Answer: By using a stack to store operands and applying operators as they are encountered

    Explanation: In postfix notation, operands are pushed onto the stack, and operators are applied to the top elements of the stack. This process continues until all elements are processed, resulting in the final evaluated value. The stack ensures operands are available in the correct order for operations.

  11. Q11Hard

    What is the output of the following Python code snippet? ```python stack = [10, 20, 30] stack.pop() stack.append(40) print(stack[-1]) ```

    • A.30
    • B.20
    • C.10
    • D.40
    Answer: 40

    Explanation: The code snippet manipulates a stack implemented as a list. The element `30` is popped, and `40` is appended. The top element of the stack after these operations is `40`, which is printed using `stack[-1]`.

  12. Q12Hard

    Which of the following is NOT a stack-based application in compilers?

    • A.Parsing expressions
    • B.Evaluating arithmetic expressions
    • C.Memory management
    • D.Sorting algorithms
    Answer: Sorting algorithms

    Explanation: Stacks are used in compilers for parsing, evaluating expressions, and managing memory. Sorting algorithms, however, are unrelated to stack usage in compilers and are typically implemented using different data structures and techniques.

Practice all 48+ Stack questions — free

Start Free Practice

Why practice Stack on AskAide?

Preparing for board exams requires more than just reading Stack from the textbook. You need to apply concepts to different types of problems. AskAide's AI-powered platform makes this process seamless for Class 12 students.

Our question bank for Stack is generated from the NCERT chapter text itself, so every question stays inside the syllabus. Whether it's complex numericals or conceptual theory, our AI tutor helps you break down every problem.

  • Unlimited practice questions for Stack
  • Personalized feedback on your weak areas
  • NCERT-aligned curriculum for Computer Science
  • Free access for students across India

Ready to ace your exams?

Students across India are already practising their chapters on AskAide — free during early access.

Try for free now
Menu