1Which data structure follows the LIFO (Last In First Out) principle?
A.Queue
B.Tree
C.Stack
D.Linked List
Correct Answer: Stack
Explanation:
A stack follows the LIFO principle, meaning the last element added is the first one to be removed.
Incorrect! Try again.
2In 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
Correct Answer: top == N - 1
Explanation:
In a 0-indexed array, the last index is N-1. If the top pointer reaches N-1, no more elements can be pushed, indicating an overflow.
Incorrect! Try again.
3What 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)
Correct Answer: O(1)
Explanation:
Pushing onto a stack involves incrementing the top pointer and assigning a value, which takes constant time O(1).
Incorrect! Try again.
4Which operation removes the top element from the stack?
A.Traverse
B.Pop
C.Peek
D.Push
Correct Answer: Pop
Explanation:
The Pop operation removes the element currently at the top of the stack and decrements the top pointer.
Incorrect! Try again.
5In 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
Correct Answer: The head of the list
Explanation:
Inserting and deleting from the head of a linked list is O(1), making it the most efficient end to represent the top of the stack.
Incorrect! Try again.
6What happens if you try to pop an element from an empty stack?
A.Stack Overflow
B.Garbage Value
C.Stack Underflow
D.System Crash
Correct Answer: Stack Underflow
Explanation:
Stack Underflow occurs when an attempt is made to remove an item from a stack that contains no elements.
Incorrect! Try again.
7Which pointer is used to track the last element added to a stack?
A.Head
B.Top
C.Front
D.Rear
Correct Answer: Top
Explanation:
The 'Top' pointer always points to the most recently added element in the stack.
Incorrect! Try again.
8What is the result of evaluating the postfix expression: 5 3 + 2 * ?
A.16
B.10
C.13
D.25
Correct Answer: 16
Explanation:
5 + 3 = 8. Then 8 * 2 = 16.
Incorrect! Try again.
9Another name for Reverse Polish Notation (RPN) is:
A.Affine Notation
B.Infix Notation
C.Postfix Notation
D.Prefix Notation
Correct Answer: Postfix Notation
Explanation:
Reverse Polish Notation places operators after their operands, which is the definition of Postfix Notation.
Incorrect! Try again.
10Convert the infix expression (A + B) * C into postfix.
A.A B + C *
B.+ A B * C
C.A + B C *
D.A B C + *
Correct Answer: A B + C *
Explanation:
The parentheses force A+B to be evaluated first (AB+), followed by multiplication with C (AB+C*).
Incorrect! Try again.
11Which data structure is primarily used to convert infix expressions to postfix expressions?
A.Queue
B.Graph
C.Stack
D.Heap
Correct Answer: Stack
Explanation:
A stack is used to hold operators and manage their precedence during the conversion from infix to postfix.
Incorrect! Try again.
12In 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
Correct Answer: Before the operands
Explanation:
In Prefix (Polish) notation, the operator precedes the operands (e.g., +AB).
Incorrect! Try again.
13What 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
Correct Answer: + A * B C
Explanation:
Multiplication has higher precedence: BC becomes BC. Then addition: + A (*BC).
Incorrect! Try again.
14When 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
Correct Answer: Push onto stack
Explanation:
Operands are pushed onto the stack. When an operator is encountered, operands are popped to perform the calculation.
Incorrect! Try again.
15Which operator has the highest precedence among the following?
A.^ (Exponentiation)
B.-
C.+
D.*
Correct Answer: ^ (Exponentiation)
Explanation:
Exponentiation typically has higher precedence than multiplication, division, addition, and subtraction.
Incorrect! Try again.
16The associativity of the exponentiation operator (^) is usually:
A.Non-associative
B.Right to Left
C.Left to Right
D.Random
Correct Answer: Right to Left
Explanation:
In most contexts, 2^3^2 is evaluated as 2^(3^2), which is Right to Left.
Incorrect! Try again.
17Which data structure follows the FIFO (First In First Out) principle?
A.Stack
B.Queue
C.Tree
D.Graph
Correct Answer: Queue
Explanation:
A Queue adds elements to the rear and removes them from the front, following FIFO.
Incorrect! Try again.
18The operation of adding an element to a queue is called:
A.Push
B.Dequeue
C.Pop
D.Enqueue
Correct Answer: Enqueue
Explanation:
Enqueue is the standard term for inserting an element into a queue.
Incorrect! Try again.
19In 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
Correct Answer: Front and Rear
Explanation:
Front tracks the first element (for deletion), and Rear tracks the last element (for insertion).
Incorrect! Try again.
20What is the initial value of Front and Rear in an empty queue (array implementation)?
A.-1
B.1
C.0
D.Null
Correct Answer: -1
Explanation:
Traditionally, -1 indicates that the pointers refer to no valid index in the array.
Incorrect! Try again.
21In a linear queue array implementation, a queue is empty when:
A.Front == Rear
B.Front == 0
C.Rear == Max - 1
D.Front == -1
Correct Answer: Front == -1
Explanation:
If Front is -1 (and usually Rear is also -1), the queue contains no elements.
Incorrect! Try again.
22What 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
Correct Answer: Empty spaces created by dequeue cannot be reused
Explanation:
Once Rear reaches the end of the array, no more elements can be added even if space exists at the beginning due to previous dequeues.
Incorrect! Try again.
23Which data structure resolves the memory wastage issue of a linear queue?
A.Stack
B.Tree
C.Priority Queue
D.Circular Queue
Correct Answer: Circular Queue
Explanation:
A Circular Queue connects the end of the array back to the beginning, allowing reuse of empty spaces.
Incorrect! Try again.
24In 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
Correct Answer: (Rear + 1) % N == Front
Explanation:
This formula checks if the next position after Rear wraps around to the current Front, indicating the buffer is full.
Incorrect! Try again.
25In 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
Correct Answer: At the Tail (Rear)
Explanation:
To maintain FIFO, new elements enter at the end (Rear) of the list.
Incorrect! Try again.
26What 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)
Correct Answer: O(1)
Explanation:
Removing from the head of a linked list requires just pointer adjustment, which is constant time.
Incorrect! Try again.
27A 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
Correct Answer: Priority Queue
Explanation:
In a Priority Queue, elements are served based on priority (highest or lowest value), not just FIFO.
Incorrect! Try again.
28Which data structure is most efficient for implementing a Priority Queue?
A.Stack
B.Array
C.Binary Heap
D.Linked List
Correct Answer: Binary Heap
Explanation:
A Binary Heap allows insertion and deletion of the highest priority element in O(log n) time, which is generally more efficient than sorted arrays or lists.
Incorrect! Try again.
29In 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
Correct Answer: The smallest number
Explanation:
In an ascending priority queue, the smallest item has the highest priority and is removed first.
Incorrect! Try again.
30What does 'Deque' stand for?
A.Double Ended Queue
B.Dynamic Queue
C.Dedicated Queue
D.Data Queue
Correct Answer: Double Ended Queue
Explanation:
Deque is an abbreviation for Double Ended Queue.
Incorrect! Try again.
31What 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
Correct Answer: Insertion and deletion allowed at both ends
Explanation:
A Deque allows operations (insert/delete) at both the Front and the Rear.
Incorrect! Try again.
32An 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
Correct Answer: Insertion at one end, deletion at both ends
Explanation:
Input-Restricted means input (insertion) is restricted to one end, but deletion is allowed at both.
Incorrect! Try again.
33An 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
Correct Answer: Insertion at both ends, deletion at one end
Explanation:
Output-Restricted means output (deletion) is restricted to one end, but insertion is allowed at both.
Incorrect! Try again.
34If 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)
Correct Answer: O(n)
Explanation:
To maintain LIFO behavior using FIFO queues, one operation (usually push) becomes expensive O(n) to rearrange elements.
Incorrect! Try again.
35Which 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
Correct Answer: Function call management (Recursion)
Explanation:
The system call stack tracks active subroutines and local variables during recursion.
Incorrect! Try again.
36Which 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
Correct Answer: Breadth First Search (BFS)
Explanation:
BFS uses a queue to explore neighbors level by level.
Incorrect! Try again.
37The 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
Correct Answer: Returns the top element without removing it
Explanation:
Peek looks at the Top element but does not modify the stack pointer.
Incorrect! Try again.
38In 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
Correct Answer: Setting its next pointer to the current head
Explanation:
The new node becomes the new head (Top), so it must point to the previous head.
Incorrect! Try again.
39For 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
Correct Answer: The queue is empty
Explanation:
If the Front pointer is null, there are no nodes in the linked list queue.
Incorrect! Try again.
40In 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
Correct Answer: (Rear + 1) % Size
Explanation:
The modulo operator handles the wrap-around from the last index back to index 0.
42What 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 + *
Correct Answer: A B C + *
Explanation:
Inside parentheses B+C becomes BC+. Then A is multiplied by that result: A BC+ *.
Incorrect! Try again.
43Which data structure supports the 'undo' feature in text editors?
A.Hash Table
B.Stack
C.Tree
D.Queue
Correct Answer: Stack
Explanation:
Undo operations reverse the most recent action, which fits the LIFO nature of a stack.
Incorrect! Try again.
44To 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
Correct Answer: Push all characters, then pop all characters
Explanation:
Pushing ABC results in C at top. Popping yields C, B, A.
Incorrect! Try again.
45In 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
Correct Answer: FIFO order
Explanation:
Standard convention for stable priority queues is to process elements with equal priority in the order they arrived (FIFO).
Incorrect! Try again.
46How many stacks are needed to implement a Queue efficiently?
A.3
B.2
C.4
D.1
Correct Answer: 2
Explanation:
Two stacks are required: one for enqueue operations and one to reverse the order for dequeue operations.
Incorrect! Try again.
47When 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
Correct Answer: Pop the stack top and print it, then repeat comparison
Explanation:
Higher precedence operators in the stack must be applied first, so they are popped before the lower precedence operator is pushed.
Incorrect! Try again.
48In 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)
Correct Answer: 1
Explanation:
Assuming the deque is not empty, deleting from index 0 moves the Front pointer to index 1.
Incorrect! Try again.
49Which operation is NOT valid for a standard Stack?
A.Pop
B.Peek
C.Delete Middle
D.Push
Correct Answer: Delete Middle
Explanation:
Standard stacks only allow access and deletion at the Top. Accessing or deleting the middle violates the ADT definition.
Incorrect! Try again.
50What is the minimum number of queues needed to implement a Stack?
A.1
B.3
C.2
D.0
Correct Answer: 2
Explanation:
Generally, two queues are used to mimic stack behavior (push/pop) by moving elements back and forth, though it can be done with 1 queue if recursion/call-stack is utilized implicitly.