Unit 3 - Practice Quiz

CSE205 50 Questions
0 Correct 0 Wrong 50 Left
0/50

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

A. Stack
B. Queue
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 == N
B. top == 0
C. top == N - 1
D. top == -1

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

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

4 Which operation removes the top element from the stack?

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

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

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

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

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

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

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

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

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

A. Between the operands
B. At the end of the expression
C. After the operands
D. Before 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. Ignore it
B. Push onto stack
C. Pop from stack
D. Evaluate immediately

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. Right to Left
B. Non-associative
C. Random
D. Left to Right

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

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

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. Start and End
B. Front and Rear
C. Top only
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 == -1
B. Rear == Max - 1
C. Front == 0
D. Front == Rear

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

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

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

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

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

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

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

A. At the Tail (Rear)
B. At the Head
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. Priority Queue
B. Linear Queue
C. Circular Queue
D. Deque

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

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

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

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

30 What does 'Deque' stand for?

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

31 What is a characteristic feature of a Deque?

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

32 An Input-Restricted Deque allows:

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

33 An Output-Restricted Deque allows:

A. Insertion and deletion at both ends
B. Insertion and deletion at one end
C. Insertion at both ends, deletion at one end
D. Insertion at one end, 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(log n)
B. O(n^2)
C. O(n)
D. O(1)

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

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

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

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

37 The Peek operation in a Stack:

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

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

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

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

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

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
C. Rear + 1
D. (Rear + 1) % Size

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

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

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

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

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

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

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. Pop the stack top and print it, then repeat comparison
B. Delete the stack top
C. Push the scanned operator
D. Ignore the scanned operator

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

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

49 Which operation is NOT valid for a standard Stack?

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

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

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