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. Queue
B. Tree
C. Stack
D. Linked List

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

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

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

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

4 Which operation removes the top element from the stack?

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

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

A. The middle of the list
B. The tail 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. Garbage Value
C. Stack Underflow
D. System Crash

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

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

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

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

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

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

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

15 Which operator has the highest precedence among the following?

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

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

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

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. Dequeue
C. Pop
D. Enqueue

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

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

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

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

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

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

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

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

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

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

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

A. Front == Rear + 1
B. Rear == N - 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 Tail (Rear)
B. At the Head
C. Randomly
D. At the Middle

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

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

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

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

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

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

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

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

30 What does 'Deque' stand for?

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

32 An Input-Restricted Deque allows:

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

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

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

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

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

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

37 The Peek operation in a Stack:

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

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. Traversing to the end of the list
C. Updating the tail pointer
D. Setting its next pointer to null

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

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

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

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

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

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

A. Use a priority queue
B. Enqueue all characters, then dequeue
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. LIFO order
B. FIFO order
C. They cannot be processed
D. Randomly

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

A. 3
B. 2
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. Size - 1
B. 1
C. 0
D. -1 (if empty)

49 Which operation is NOT valid for a standard Stack?

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

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

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