Unit 3: Stacks and Queues - Practice Quiz

CSE205 — Data Structures And Algorithms 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 Which data structure follows the LIFO (Last In First Out) principle?

A. Linked List
B. Stack
C. Queue
D. Tree

2 In a stack implemented using an array of size N, what is the condition for stack overflow?

A. top == 0
B. top == -1
C. top == N - 1
D. top == N

3 What is the time complexity of the push operation in a stack implemented using an array?

A. O(1)
B. O(n^2)
C. O(log n)
D. O(n)

4 Which operation removes the top element from the stack?

A. Peek
B. Pop
C. Traverse
D. Push

5 In a linked list representation of a stack, where are elements pushed and popped from?

A. The tail of the list
B. The middle of the list
C. The head of the list
D. Random positions

6 What happens if you try to pop an element from an empty stack?

A. System Crash
B. Stack Underflow
C. Stack Overflow
D. Garbage Value

7 Which pointer is used to track the last element added to a stack?

A. Head
B. Top
C. Rear
D. Front

8 What is the result of evaluating the postfix expression: 5 3 + 2 * ?

A. 10
B. 13
C. 16
D. 25

9 Another name for Reverse Polish Notation (RPN) is:

A. Prefix Notation
B. Infix Notation
C. Postfix Notation
D. Affine Notation

10 Convert the infix expression (A + B) * C into postfix.

A. + A B * C
B. A B C + *
C. A B + C *
D. A + B C *

11 Which data structure is primarily used to convert infix expressions to postfix expressions?

A. Stack
B. Heap
C. Queue
D. Graph

12 In Polish notation (Prefix), where is the operator placed?

A. At the end of the expression
B. Between the operands
C. Before the operands
D. After the operands

13 What is the prefix form of the expression: A + B * C ?

A. A B C * +
B. * + A B C
C. + A * B C
D. + * A B C

14 When evaluating a postfix expression, what do you do when you encounter an operand?

A. Pop from stack
B. Evaluate immediately
C. Ignore it
D. Push onto stack

15 Which operator has the highest precedence among the following?

A. *
B. -
C. +
D. ^ (Exponentiation)

16 The associativity of the exponentiation operator (^) is usually:

A. Left to Right
B. Right to Left
C. Non-associative
D. Random

17 Which data structure follows the FIFO (First In First Out) principle?

A. Tree
B. Stack
C. Queue
D. Graph

18 The operation of adding an element to a queue is called:

A. Push
B. Pop
C. Dequeue
D. Enqueue

19 In an array implementation of a simple queue, which pointers are maintained?

A. Top only
B. Front and Rear
C. Start and End
D. Head and Tail

20 What is the initial value of Front and Rear in an empty queue (array implementation)?

A. -1
B. Null
C. 1
D. 0

21 In a linear queue array implementation, a queue is empty when:

A. Front == 0
B. Front == -1
C. Rear == Max - 1
D. Front == Rear

22 What is the major drawback of a simple linear queue implemented with an array?

A. It is slow
B. It uses too much memory
C. Empty spaces created by dequeue cannot be reused
D. It cannot handle integers

23 Which data structure resolves the memory wastage issue of a linear queue?

A. Circular Queue
B. Stack
C. Priority Queue
D. Tree

24 In a Circular Queue of size N, the condition for the queue being full is:

A. Front == Rear + 1
B. (Rear + 1) % N == Front
C. Front == 0
D. Rear == N - 1

25 In a linked list implementation of a queue, where is the Enqueue operation performed?

A. At the Middle
B. Randomly
C. At the Head
D. At the Tail (Rear)

26 What is the time complexity for Dequeue operation in a linked list implementation (assuming a head pointer)?

A. O(1)
B. O(n)
C. O(n^2)
D. O(log n)

27 A queue where elements are removed based on a specific value rather than arrival time is called:

A. Circular Queue
B. Priority Queue
C. Deque
D. Linear Queue

28 Which data structure is most efficient for implementing a Priority Queue?

A. Stack
B. Array
C. Linked List
D. Binary Heap

29 In an Ascending Priority Queue, which element is removed first?

A. The first number inserted
B. The last number inserted
C. The smallest number
D. The largest number

30 What does 'Deque' stand for?

A. Dynamic Queue
B. Double Ended Queue
C. Dedicated Queue
D. Data Queue

31 What is a characteristic feature of a Deque?

A. Insertion and deletion at one end only
B. Insertion at one end, deletion at the other
C. Elements are always sorted
D. Insertion and deletion allowed at both ends

32 An Input-Restricted Deque allows:

A. Insertion at both ends, deletion at one end
B. Insertion and deletion at one end
C. Insertion and deletion at both ends
D. Insertion at one end, deletion at both ends

33 An Output-Restricted Deque allows:

A. Insertion and deletion at one end
B. Insertion at one end, deletion at both ends
C. Insertion and deletion at both ends
D. Insertion at both ends, deletion at one end

34 If you implement a Stack using two Queues, what is the cost of the Push operation usually made to be?

A. O(log n)
B. O(n)
C. O(1)
D. O(n^2)

35 Which of the following is an application of a Stack?

A. Breadth First Search
B. Function call management (Recursion)
C. CPU process scheduling
D. Printer spooling

36 Which of the following is an application of a Queue?

A. Evaluating postfix expressions
B. Breadth First Search (BFS)
C. Undo mechanism in text editors
D. Checking for balanced parentheses

37 The Peek operation in a Stack:

A. Returns the top element without removing it
B. Removes the top element
C. Returns the bottom element
D. Clears the stack

38 In a linked list implementation of a stack, pushing an element requires allocating a new node and:

A. Setting its next pointer to null
B. Traversing to the end of the list
C. Setting its next pointer to the current head
D. Updating the tail pointer

39 For a queue implemented with a linked list, if Front == NULL, it means:

A. The queue has one element
B. Error condition
C. The queue is empty
D. The queue is full

40 In the array representation of a circular queue, how do you calculate the next position for Rear?

A. (Rear - 1) % Size
B. (Rear + 1) % Size
C. Rear - 1
D. Rear + 1

41 Evaluate the prefix expression: - + 7 * 4 5 + 2 0

A. 20
B. 30
C. 15
D. 25

42 What is the result of converting A * (B + C) to postfix?

A. A * B + C
B. A B + C *
C. A B C + *
D. * A + B C

43 Which data structure supports the 'undo' feature in text editors?

A. Hash Table
B. Queue
C. Tree
D. Stack

44 To reverse a string using a stack, you would:

A. Push half, pop half
B. Push all characters, then pop all characters
C. Enqueue all characters, then dequeue
D. Use a priority queue

45 In a priority queue, if two elements have the same priority, how are they typically processed?

A. FIFO order
B. Randomly
C. LIFO order
D. They cannot be processed

46 How many stacks are needed to implement a Queue efficiently?

A. 2
B. 3
C. 4
D. 1

47 When transforming an infix expression to postfix, if the scanned operator has lower precedence than the stack top operator:

A. Ignore the scanned operator
B. Push the scanned operator
C. Pop the stack top and print it, then repeat comparison
D. Delete the stack top

48 In a Deque implemented using a circular array, if Front = 0 and we do deleteFront, what is the new Front?

A. 1
B. Size - 1
C. 0
D. -1 (if empty)

49 Which operation is NOT valid for a standard Stack?

A. Peek
B. Push
C. Pop
D. Delete Middle

50 What is the minimum number of queues needed to implement a Stack?

A. 3
B. 2
C. 1
D. 0