Unit 3 - Practice Quiz

CSE205

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

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

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

A. top == -1
B. top == 0
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)
C. O(log n)
D. O(n^2)

4 Which operation removes the top element from the stack?

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

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. Stack Overflow
B. Stack Underflow
C. Garbage Value
D. System Crash

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

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

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

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

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

A. Infix Notation
B. Prefix 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. Queue
B. Stack
C. Heap
D. Graph

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

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

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. Push onto stack
C. Evaluate immediately
D. Ignore it

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. Random
D. Non-associative

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

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

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

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

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

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

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

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

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

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

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. Stack
B. Circular Queue
C. Priority Queue
D. Tree

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

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

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

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

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(log n)
D. O(n^2)

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

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

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

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

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

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

30 What does 'Deque' stand for?

A. Dedicated Queue
B. Double Ended Queue
C. Dynamic 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. Insertion and deletion allowed at both ends
D. Elements are always sorted

32 An Input-Restricted Deque allows:

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

33 An Output-Restricted Deque allows:

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

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

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

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

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

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

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

37 The Peek operation in a Stack:

A. Removes the top element
B. Returns the top element without removing it
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 the current head
B. Setting its next pointer to null
C. Traversing to the end of the list
D. Updating the tail pointer

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

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

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

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

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

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

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. Queue
B. Stack
C. Tree
D. Hash Table

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

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

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

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

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

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

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

A. Push the scanned operator
B. Pop the stack top and print it, then repeat comparison
C. Ignore the scanned operator
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.
B. 1
C. Size - 1
D. -1 (if empty)

49 Which operation is NOT valid for a standard Stack?

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

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

A. 1
B. 2
C. 3
D.