1) Which of the following represents the Postfix notation of the expression:
A+ B∗C
A) AB+C*
B) ABC*+
C) A+BC*
D) ABC+
E) ABC+
Answer: B
2) Convert the following infix expression to postfix:
7+ 8−6∗3/2
A) 7 8 + 6 3 * 2 / -
B) 7 8 + 6 3 2 * / -
C) 7 8 6 3 * 2 / + -
D) 7 8 + 6 3 * / 2 -
E) 7 8 6 + 3 * 2 / -
Answer: A
3) Evaluate the following postfix expression:
53*2+64*+
A) 39
B) 41
C) 42
D) 43
E) 44
Answer: B
4) Which of the following is NOT a type of arithmetic expression notation?
A) Infix
B) Prefix
C) Postfix
D) Binaryfix
E) Arithmetic expression
Answer: D
5)A Stack follows which principle?
A) FIFO
B) FILO
C) LIFO
D) LILO
E) FILL
Answer: C
6)Which operation adds an element to a stack?
A) enqueue
B) dequeue
C) push
D) delete
E) search
Answer: C
7) Which operation removes an element from a stack?
A) enqueue
B) pop
C) push
D) merge
E) insert
Answer: B
8)Which of the following operations is associated with Queue?
A) push
B) pop
C) enqueue
D) top
E) stack
Answer: C
9) In a queue, elements are removed from the:
A) rear
B) front
C) middle
D) top
E) bottom
Answer: B
10) In a queue, elements are inserted at the:
A) front
B) rear
C) top
D) middle
E) bottom
Answer: B
11) Given the following stack operations:
Push(A)
Push(B)
Push(C)
Pop()
What element will be returned?
A) A
B) B
C) C
D) D
E) None
Answer: C
12)If a stack is full and we try to insert another element, the condition is
called:
A) Underflow
B) Overflow
C) Empty stack
D) Memory error
E) Stack crash
Answer: B
13) If a stack is empty and we try to pop an element, the condition is called:
A) Overflow
B) Underflow
C) Memory leak
D) Stack error
E) Null pointer
Answer: B
14) Given:
Base Address = 2001
Element size = 2 bytes
Find the address of x[4]
A) 2005
B) 2006
C) 2007
D) 2008
E) 2010
Answer: C
15) Which of the following expressions is balanced?
A) ((()))
B) ([)]
C) (A+B]
D) ((A+B)
E) )A+B(
Answer: A
16) Which data structure is used to check balanced parentheses?
A) Queue
B) Tree
C) Array
D) Linked List
E) Stack
Answer: E
17) Which principle does a Queue follow?
A) LIFO
B) FIFO
C) FILO
D) LILO
E) FOFI
Answer: B
18) If the simple queue contains:
4, 8, 6
Which element will be removed first?
A) 6
B) 8
C) 4
D) 2
E) 5
Answer: C
19) Convert the following infix expression to postfix:
(a+b)*c
A) ab+c*
B) abc*+
C) a+bc
D) ab+c
E) ab*c+
Answer: A
20) Convert the following infix expression to postfix:
a-b/(c+d*e)
A) a b c d e * + / -
B) a b c d e + * / -
C) a b c d e * + - /
D) a b c d e * / + -
E) a b c d e + / * -
Answer: A
21) Which operator has the highest precedence?
A) +
B) −
C) *
D) /
E) ^
Answer: E
22) Which structure is used to convert infix to postfix?
A) Queue
B) Stack
C) Tree
D) Graph
E) Heap
Answer: B
23) Which of the following is an example of dynamic data structure?
A) Array
B) Table
C) Stack using array
D) Linked list
E) Matrix
Answer: D
24) Which of the following is a linear data structure?
A) Graph
B) Tree
C) Stack
D) Network
E) Heap
Answer: C
25) Which of the following is a non-linear data structure?
A) Array
B) Queue
C) Stack
D) Tree
E) List
Answer: D
26) What is the main advantage of dynamic data structures?
A) Fixed size
B) Faster access
C) Flexible size
D) Static memory
E) No memory allocation
Answer: C
27) Convert the following infix expression to postfix:
( A+ B)∗(C−D)/E
A) AB+CD-E/
B) AB+CD-/E
C) AB+CD-*E/
D) ABCD+-E/
E) AB+CD-/E
Answer: C
28) Evaluate the postfix expression:
832*+5-
A) 9
B) 8
C) 7
D) 6
E) 5
Answer: A
29) A stack initially contains:
top → 7
5
2
After executing:
Push(4)
Push(6)
Pop()
What is the new top?
A) 4
B) 5
C) 6
D) 7
E) 2
Answer: A
30) If the stack size is 5 and currently top = 4, performing Push(X) will
result in:
A) Underflow
B) Overflow
C) Normal insertion
D) Stack reset
E) No change
Answer: B
31) If a stack contains:
D
C
B
A
(top = D)
What sequence will be returned by four pop operations?
A) A B C D
B) D C B A
C) B C D A
D) C B A D
E) A D C B
Answer: B
32) Which of the following expressions is NOT balanced?
A) {[(A+B)]}
B) ((A+B)(C+D))
C) [A+(BC)]
D) (A+B](C+D)
E) {A+[B(C+D)]}
Answer: D
33) The algorithm for checking balanced parentheses mainly uses:
A) Queue
B) Stack
C) Array
D) Tree
E) Graph
Answer: B
34) A queue has the elements:
Front → 4 8 6 3 ← Rear
After performing Dequeue(), Dequeue(), the queue becomes:
A) 8 6 3
B) 4 8 6
C) 6 3
D) 4 6 3
E) 8 6
Answer: C
35) If we perform the following operations:
Enqueue(3)
Enqueue(6)
Enqueue(9)
Dequeue()
Which element is removed?
A) 9
B) 6
C) 3
D) None
E) Error
Answer: C
36) For a 2D array stored column-wise:
A[6][8]
Base = 2000
Size = 2
Find location A(2,3)
A) 2022
B) 2024
C) 2026
D) 2028
E) 2030
Answer: C
37) Input sequence to stack:
12345
Which of the following cannot be a valid pop sequence?
A) 5 4 3 2 1
B) 2 1 4 3 5
C) 3 2 5 4 1
D) 4 3 5 1 2
E) 2 4 5 3 1
Answer: D
38) If push operations are represented by S and pop operations by U, what
is the output sequence for:
Input: D A T W R
Sequence: SSUUSUSUSU
A) A D T R W
B) A D W T R
C) A D T W R
D) D A W T R
E) D A T R W
Answer: C
39) Which data structure allows insertion and deletion only at one end?
A) Queue
B) Stack
C) Tree
D) Graph
E) Linked list
Answer: B
41) Given stack operations:
Push(1)
Push(2)
Pop()
Push(3)
Push(4)
Pop()
Pop()
What elements are popped?
A) 1 4 3
B) 2 4 3
C) 2 3 4
D) 1 3 4
E) 2 4 1
Answer: B
42) Simple Queue size = 6
Initial state:
front = -1
rear = -1
Operations:
Enqueue A
Enqueue B
Enqueue C
Dequeue
Enqueue D
Final values of front and rear are:
A) front=2 rear=4
B) front=1 rear=4
C) front=2 rear=3
D) front=1 rear=3
E) front=3 rear=4
Answer: D
43) In a circular queue of size 5, after the following operations:
Insert A B C D
Delete 2 elements
Insert E F
What is the rear position?
A) 1
B) 2
C) 3
D) 4
E) 0
Answer: E
44) Which of the following expressions is correctly balanced?
A) ( [ { } ] )
B) ( [ { ] } )
C) { ( [ ) ] }
D) [ ( { } )
E) ( ( [ ] )
Answer: A
45) Which expression will cause stack mismatch during parentheses
checking?
A) (A+B)*(C+D)
B) (A+B]C
C) ((A+B))
D) (A+B+C)
E) A+(BC)
Answer: B
45) Input sequence: 12345
Which output sequence is valid for stack?
A) 3 2 1 5 4
B) 4 3 5 1 2
C) 2 4 3 5 1
D) 1 5 4 3 2
E) 5 3 4 2 1
Answer: A
46) Evaluate the postfix expression:
952+8*+3-
A) 64
B) 63
C) 62
D) 61
E) 60
Answer: C
Steps
5+2 = 7
7×8 = 56
9+56 = 65
65−3 = 62
47) Evaluate the prefix expression:
+9*23
A) 12
B) 15
C) 16
D) 18
E) 21
Answer: B
Explanation
2×3 = 6
9+6 = 15
---------------------------------------------------------------------------------------------
---------------
48) Stack operations:
Push(2)
Push(4)
Push(6)
Pop()
Push(8)
Pop()
Pop()
Which values are popped?
A) 6 8 4
B) 6 8 2
C) 6 4 8
D) 4 6 8
E) 8 6 4
Answer: A
49) Which algorithm step detects stack overflow?
A) if top == 0
B) if top >= size
C) if top <= size
D) if stack empty
E) if size = 0
Answer: B
50) Which condition indicates stack underflow?
A) top == size
B) top < 0
C) top >= size
D) stack full
E) stack reset
Answer: B
50) A two-dimensional array A(7,3) requires 2 bytes for each element.
If the array is stored in row-major order and the address of element A(6,2)
= 114, what is the base address?
A) 80
B) 82
C) 84
D) 86
E) 88
Answer: B
51) Given an empty stack (s) and queue (q):
[Link](3)
[Link](1)
[Link]([Link]())
[Link](5)
[Link](19)
[Link](12)
[Link]([Link]())
[Link]()
What will be the top element of the stack?
A) 3
B) 5
C) 19
D) 12
E) 1
Answer: B
52) A 2D array X[5,4] is stored in column-major order. Each element
requires 2 bytes and base address = 500. Find the address of X[3,2].
A) 514
B) 516
C) 518
D) 520
E) 522
Answer: A
53) A circular queue of size 5 initially contains:
[10, 20, 30, -, -]
Front = 0
Rear = 2
After operations:
Enqueue(40)
Enqueue(50)
Dequeue()
Enqueue(60)
What is the Front position?
A) 2
B) 3
C) 4
D) 0
E) 1
Answer: E
54) Which application commonly uses a queue?
A) Recursion
B) Undo operation
C) Printer management
D) Function calls
E) Stack memory
Answer: C
55) Which data structure allows fastest access to elements?
A) Linked list
B) Queue
C) Array
D) Stack
E) Tree
Answer: C
56) The pop operation removes an element from the:
A) Bottom
B) Middle
C) Top
D) Rear
E) Front
Answer: C
57) Trace the following and write down the final value of stack and queue if
suppose we have empty stack and queue Stack s; Queue q; s. push (3); s.
push (1);
q. enqueue (s. pop()); s. push (5); q. enqueue (19); q. enqueue (12); s.
push(q. dequeue ()); s. pop();
Here is the trace step by step, assuming both stack s and queue q are
initially empty.
A) Stack = 3, 1 Queue = 19, 12
B) Stack = 5, 3 Queue = 12, 19
C) Stack = 3 Queue = 1, 19, 12
D) Stack= 3, 5 Queue: 19, 12
E) Stack = 5 Queue = 19
Answer: D
58) Consider the following statements. Assume S1 is a stack and Q1 is a
simple queue, and both are initially empty. What are the final contents of
Stack S1 and Queue Q1?
int x, y
x=7,y=9
[Link](5)
[Link](10)
[Link](x)
[Link](x)
[Link]()
[Link]([Link]())
[Link](y)
[Link](x*y)
[Link]([Link]())
A) Stack S1 = 5 Queue Q1 = 7, 10, 63, 9
B) Stack S1 = 10 Queue Q1 = 7, 63, 9
C) Stack S1 = 5, 9 Queue Q1 = 7, 10, 9
D) Stack S1 = empty Queue Q1 = 7, 10, 63
E) Stack S1 = 9 Queue Q1 = 7, 10, 63, 5
Answer: A
Stack S1 = 5
Queue Q1 = 7, 10, 63, 9