VAGDEVI VILAS COLLEGE – HALASAHALLI 560087
II PU COMPUTER SCIENCE
STACK – MCQ With Answers ( Ch 03 )
1 What is the principle of a stack?
A) FIFO B) LIFO
C) LILO D) FIFS
Answer : B
2 Which operation inserts an element into a stack?
A) pop B) insert
C) push D) append
Answer : C
3 Which operation removes the top element of a stack?
A) delete B) remove
C) pop D) push
Answer : C
4 What happens when a pop operation is performed on an empty stack?
A) Underflow B) Overflow
C) Error 404 D) Memory leak
Answer : A
5 Which data structure is used for recursion?
A) Queue B) Tree
C) Stack D) Linked List
Answer : C
6 Which of the following is not an application of stacks?
A) Undo mechanism B) Backtracking
C) Parsing expressions D) Disk scheduling
Answer : D
7 Which of the following is true about stack?
A) Insertion happens at rear B) Deletion happens at front
C) Insertion and deletion both happen at the top D) None
Answer : C
8 The memory required by a stack depends on:
A) Type of data B) Number of elements
C) Time of use D) Operating system
Answer : B
9 Which condition indicates that a stack is full (in array implementation)?
A) top == 0 B) top == -1
C) top == size - 1 D) top == size + 1
Answer : C
10 What does the peek() function return?
A) Bottom element B) Middle element
C) Top element D) All elements
Answer : C
VAGDEVI VILAS COLLEGE – HALASAHALLI 560087
II PU COMPUTER SCIENCE
STACK – MCQ With Answers ( Ch 03 )
11 Stack underflow occurs when:
A) Inserting into a full stack B) Removing from an empty stack
C) Stack is sorted D) Stack is too large
Answer : B
12 Which of these is not a valid stack operation?
A) push B) pop
C) insert D) peek
Answer : C
13 Which of the following can reverse a string?
A) Queue B) Stack
C) Array D) Hash table
Answer : B
14 Which of the following is used for undo features in text editors?
A) Queue B) Stack
C) Heap D) Tree
Answer : B
15 Stack works on which memory concept?
A) Sequential B) Associative
C) Contiguous D) Last-in-first-out
Answer : D
16 What is the output of popping from an empty stack?
A) 0 B) Error/Exception
C) -1 D) Null
Answer : B
17 Which Python list method is used to push elements to a stack?
A) append() B) insert()
C) extend() D) push()
Answer : A
18 Which method refers the top element from a Python list stack?
A) peek( ) B) remove()
C) pop() D) clear()
Answer : A
19 What is the output of this code? stack = [1, 2, 3]; stack.pop()
A) 1 B) 2
C) 3 D) Error
Answer : C
20 How do you check if a stack is empty in Python?
A) len(stack) != 0 B) stack == []
C) not stack D) All of the above
Answer : D
VAGDEVI VILAS COLLEGE – HALASAHALLI 560087
II PU COMPUTER SCIENCE
STACK – MCQ With Answers ( Ch 03 )
21 Which of the following is not a valid method in Python?
A) pop() B) append()
C) insert(0, x) D) peek()
Answer : D
22 How can you implement peek in a Python stack s?
A) s.peek() B) s[len(s)]
C) s[-1] D) s.pop()
Answer : C
23 What is the output? s = []; s.append(10); s.append(20); s.pop()
A) 10 B) 20
C) None D) Error
Answer : B
24 In Python, What will stack.pop(0) do?
A) Remove top B) Remove bottom
C) Error D) Remove middle
Answer : B
25 What is the output of: stack = []; stack.append(1); print(stack[-1])
A) 0 B) 1
C) Error D) None
Answer : B
26 Which is postfix of (A + B)?
A) AB+ B) A+B
C) +AB D) (A+B)
Answer : A
27 Postfix expression is also called:
A) Prefix B) Infix
C) Polish notation D) Reverse Polish notation
Answer : D
28 Which of these follows postfix order?
A) Operator between operands B) Operator before operands
C) Operator after operands D) None
Answer : C
29 What is the postfix of A + B * C?
A) ABC*+ B) AB+C*
C) A+BC* D) ABC+
Answer : A
30 Which stack operation is used during postfix evaluation?
A) push B) pop
C) both A & B D) None
Answer : C
VAGDEVI VILAS COLLEGE – HALASAHALLI 560087
II PU COMPUTER SCIENCE
STACK – MCQ With Answers ( Ch 03 )
31 What is the result of postfix: 2 3 * 5 4 * + ?
A) 17 B) 26
C) 23 D) 30
Answer : A
32 Which of the following is a valid postfix expression?
A) A + B B) AB+
C) +AB D) A + B * C
Answer : B
33 In postfix, which element is processed first?
A) Operator B) Left operand
C) Right operand D) Depends
Answer : B
34 In evaluating 4 2 + 5 *, what is the output?
A) 30 B) 21
C) 16 D) 27
Answer : A
35 What is used to convert infix to postfix?
A) Queue B) Heap
C) Stack D) Tree
Answer : C
36 Which comes first in postfix: operand or operator?
A) Operand B) Operator
C) Both D) None
Answer : A
37 Postfix of (A + B) * (C + D) is:
A) AB+CD+* B) ABCD++*
C) A+B+C+D* D) AB+CD+
Answer : A
38 Which of the following cannot be evaluated using a stack?
A) Prefix B) Infix
C) Postfix D) All can be
Answer : D
39 What happens when an operator is found in postfix evaluation?
A) It is pushed B) Operands are popped
C) Stack is cleared D) None
Answer : B
40 Postfix notation eliminates the need for:
A) Operands B) Parentheses
C) Operators D) Functions
Answer : B