1Which data structure follows the LIFO (Last In First Out) principle?
A.Queue
B.Stack
C.Linked List
D.Tree
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 == 0
C.top == N - 1
D.top == N
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(1)
B.O(n)
C.O(log n)
D.O(n^2)
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.Push
B.Pop
C.Peek
D.Traverse
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 tail of the list
B.The middle 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.Stack Underflow
C.Garbage Value
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.Front
B.Rear
C.Top
D.Head
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.13
C.25
D.10
Correct Answer: 16
Explanation:5 + 3 = 8. Then 8 * 2 = 16.
Incorrect! Try again.
9Another name for Reverse Polish Notation (RPN) is:
A.Infix Notation
B.Prefix Notation
C.Postfix Notation
D.Affine 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.Stack
C.Heap
D.Graph
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.After the operands
B.Between the operands
C.Before the operands
D.At the end of the expression
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.Push onto stack
C.Evaluate immediately
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.+
B.-
C.*
D.^ (Exponentiation)
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.Left to Right
B.Right to Left
C.Random
D.Non-associative
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.Pop
C.Enqueue
D.Dequeue
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.Front and Rear
C.Head and Tail
D.Start and End
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.
B.1
C.-1
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 == -1
C.Rear == Max - 1
D.Front == 0
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 is slow
B.It uses too much memory
C.Empty spaces created by dequeue cannot be reused
D.It cannot handle integers
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.Circular Queue
C.Priority Queue
D.Tree
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.Rear == N - 1
B.Front == Rear + 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 Head
B.At the Tail (Rear)
C.At the Middle
D.Randomly
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(1)
B.O(n)
C.O(log n)
D.O(n^2)
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.Circular Queue
B.Deque
C.Priority Queue
D.Linear 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.Array
B.Linked List
C.Binary Heap
D.Stack
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 smallest number
C.The first number inserted
D.The last number inserted
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.Dedicated Queue
B.Double Ended Queue
C.Dynamic 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 at one end, deletion at the other
C.Insertion and deletion allowed at both ends
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 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
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 one end
D.Insertion and deletion at both ends
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(n)
C.O(log n)
D.O(n^2)
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.CPU process scheduling
C.Function call management (Recursion)
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.Undo mechanism in text editors
B.Checking for balanced parentheses
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.Removes the top element
B.Returns the top element without removing it
C.Returns the bottom element
D.Clears the stack
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.Setting its next pointer to null
C.Traversing to the end of the list
D.Updating the tail pointer
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 full
B.The queue is empty
C.The queue has one element
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
B.(Rear + 1) % Size
C.Rear - 1
D.(Rear - 1) % Size
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.Queue
B.Stack
C.Tree
D.Hash Table
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.Push all characters, then pop all characters
B.Enqueue all characters, then dequeue
C.Use a priority queue
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.Randomly
B.LIFO order
C.FIFO order
D.They cannot be processed
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.1
B.2
C.3
D.4
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.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
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.
B.1
C.Size - 1
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.Push
B.Pop
C.Peek
D.Delete Middle
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.2
C.3
D.
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.
Incorrect! Try again.
Give Feedback
Help us improve by sharing your thoughts or reporting issues.