0% found this document useful (0 votes)
24 views3 pages

File - 884729453 - 1694060717 - Stack&queue 10 MCQ

This document contains 10 multiple choice questions about stacks and queues in data structures. 1. The questions cover topics like pop and push operations on a stack, the differences between LIFO and FIFO data structures, detecting empty and full conditions in a circular queue, dequeues allowing insertion and deletion from both ends, and order of removal from a queue. 2. It also includes a question on evaluating an infix expression using stack operations and precedence rules. 3. The answers to each question are provided to check understanding of key concepts related to stacks and queues.

Uploaded by

Rakesh S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

File - 884729453 - 1694060717 - Stack&queue 10 MCQ

This document contains 10 multiple choice questions about stacks and queues in data structures. 1. The questions cover topics like pop and push operations on a stack, the differences between LIFO and FIFO data structures, detecting empty and full conditions in a circular queue, dequeues allowing insertion and deletion from both ends, and order of removal from a queue. 2. It also includes a question on evaluating an infix expression using stack operations and precedence rules. 3. The answers to each question are provided to check understanding of key concepts related to stacks and queues.

Uploaded by

Rakesh S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PYTHON WORKSHOP

MCQ ON STACK & QUEUES


Q1 Write the O/P of the following code

push(5)
since if you print pop, you can see the
push(8) deleted element. that is what 85251 is
pop
push(2)
push(5)
pop
pop
pop
push(1)
pop

a) 85251 b)85521 c)82551 d)81255

Ans = a
Q2 Insertion and Deletion operation in Queue is known as ?
a) PUSH & POP
b) Enqueue and Dequeue
c) Insert and Delete
d) None

Ans = b)
Q3 Stack in Data Structure is ___________.
A) LIFO
B) FIFO
C) LEFO
D) FEFO

Ans: a)
Q4 In the stack, If user try to remove element from the empty stack then it called as
___________.
a) Empty Collection
b) Overflow of stack
c) Garbage Collection
d) Underflow of Stack
Ans =d
Q5 void fun(Queue *Q)
{
Stack S; // Say it creates an empty stack S

// Run while Q is not empty dequeues item from Q via fifo and puts into
stack in same order. but when popping
while (!isEmpty(Q)) from stack, lifo so order reversed when
reinputting into queue
{
// deQueue an item from Q and push the dequeued item to S
push(&S, deQueue(Q));
}

// Run while Stack S is not empty


while (!isEmpty(&S))
{
// Pop an item from S and enqueue the poppped item to Q
enQueue(Q, pop(&S));
}
}
What does the above function do in general?
(A) Removes the last from Q
(B) Keeps the Q same as it was before the call
(C) Makes Q empty
(D) Reverses the Q

Ans = d)
Q6 Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n
elements. Assume that the insertion and deletion operation are carried out using REAR and
FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to
detect queue full and queue empty are

(A) Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT


(B) Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR
(C) Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT
(D) Full: (FRONT+1) mod n == REAR, empty: REAR == FRONT

Ans= a)
Q7 A data structure in which elements can be inserted or deleted at/from both the ends but
not in the middle is?

a) Queue
b) Circular queue
c) Dequeue
d) Priority queue

Ans= c)

Q8 If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time,
in what order will they be removed?
a) ABCD
b) DCBA
c) DCAB
d) ABDC

Ans= a)

Q9 A peek can be simulated by accessing the element with which index


a) 0
b) 1
c) -1 most recent/ last element

d) Rear
Ans=c

Q10 Write the equivalent infix expression for : 10,3,*,7,-,*,23,+


a) 10*3*(7-1)+23
b) 10*3+(7=1)+23
c) 10*3*(7*1)-23
d) 103*(7-1)+23
Ans=a)

You might also like