Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Linear Data StructuresEasy
Q1. What is a stack?
- A.A LIFO data structure✓ Correct
- B.A FIFO data structure
- C.A random access data structure
- D.A hierarchical data structure
Explanation
A stack follows the Last-In-First-Out (LIFO) principle where the last element added is the first one removed.
Report an error in this question
Linear Data StructuresEasy
Q2. What is a queue?
- A.A sorted data structure
- B.A FIFO data structure✓ Correct
- C.A LIFO data structure
- D.A tree-based data structure
Explanation
A queue follows the First-In-First-Out (FIFO) principle where the first element added is the first one removed.
Report an error in this question
Linear Data StructuresEasy
Q3. Which operation adds an element to the top of a stack?
- A.Push✓ Correct
- B.Dequeue
- C.Enqueue
- D.Pop
Explanation
The push operation adds an element to the top of a stack.
Report an error in this question
Linear Data StructuresEasy
Q4. What is a linked list?
- A.Nodes where each node points to the next node✓ Correct
- B.A hierarchical tree-based data structure
- C.Elements stored in contiguous memory locations
- D.A hash-based key-value pair structure
Explanation
A linked list is a linear data structure consisting of nodes, where each node contains data and a reference (pointer) to the next node.
Report an error in this question
Linear Data StructuresEasy
Q5. What is the time complexity of inserting an element at the beginning of a singly linked list?
- A.O(n^2)
- B.O(log n)
- C.O(1)✓ Correct
- D.O(n)
Explanation
Inserting at the beginning of a linked list only requires updating the head pointer, which takes O(1) time.
Report an error in this question
Linear Data StructuresEasy
Q6. Which data structure is used to evaluate postfix expressions?
- A.Array
- B.Stack✓ Correct
- C.Queue
- D.Linked List
Explanation
A stack is used to evaluate postfix expressions by pushing operands and popping them when an operator is encountered.
Report an error in this question
Linear Data StructuresEasy
Q7. What is the main disadvantage of an array?
- A.Random access is not possible
- B.Fixed size in static arrays✓ Correct
- C.It cannot store integers
- D.Elements cannot be sorted
Explanation
Static arrays have a fixed size that must be declared at creation time and cannot be changed dynamically.
Report an error in this question
Linear Data StructuresEasy
Q8. What does the 'dequeue' operation do?
- A.Adds an element to the front of a queue
- B.Removes an element from the front of a queue✓ Correct
- C.Adds an element to the rear of a queue
- D.Removes an element from the rear of a queue
Explanation
The dequeue operation removes and returns the element at the front of the queue.
Report an error in this question
Linear Data StructuresEasy
Q9. In a singly linked list, the last node points to:
- A.The first node
- B.NULL (nothing)✓ Correct
- C.The middle node
- D.Itself (self)
Explanation
In a singly linked list, the last node's next pointer is NULL, indicating the end of the list.
Report an error in this question
Linear Data StructuresEasy
Q10. Which operation removes an element from the top of a stack?
- A.Enqueue
- B.Push
- C.Peek
- D.Pop✓ Correct
Explanation
The pop operation removes and returns the element from the top of the stack.
Report an error in this question
Linear Data StructuresMedium
Q11. What is a circular queue?
- A.A queue implemented using a linked list
- B.A queue where the rear connects back to front✓ Correct
- C.A double-ended queue with two pointers
- D.A queue that automatically sorts elements
Explanation
A circular queue connects the rear to the front, utilizing the entire array space and avoiding the problem of unused space in linear queues.
Report an error in this question
Linear Data StructuresMedium
Q12. What is a doubly linked list?
- A.A list with pointers to both next and previous✓ Correct
- B.A list that stores two data values per node
- C.A list structure with two separate heads
- D.A circular list with bidirectional traversal
Explanation
A doubly linked list has nodes that contain pointers to both the next and the previous nodes, allowing traversal in both directions.
Report an error in this question
Linear Data StructuresMedium
Q13. What is a deque (double-ended queue)?
- A.A stack implemented as a queue structure
- B.A priority queue with weighted elements
- C.A queue allowing deletion from both ends only
- D.A structure allowing insert and delete at both ends✓ Correct
Explanation
A deque (double-ended queue) allows insertion and deletion of elements from both the front and rear ends.
Report an error in this question
Linear Data StructuresMedium
Q14. What is the time complexity of deleting a node from the middle of a singly linked list (given a pointer to the previous node)?
- A.O(1)✓ Correct
- B.O(log n)
- C.O(n)
- D.O(n^2)
Explanation
If you have a pointer to the previous node, deletion takes O(1) by simply updating the next pointer.
Report an error in this question
Linear Data StructuresMedium
Q15. How can you implement a queue using two stacks?
- A.It is not possible to implement using stacks
- B.Use both stacks for enqueue operations only
- C.Use one stack for enqueue and another for dequeue✓ Correct
- D.Merge both stacks into a single combined structure
Explanation
One stack is used for enqueue (push). For dequeue, if the second stack is empty, all elements from the first are popped and pushed to the second, then popped from the second.
Report an error in this question
Linear Data StructuresMedium
Q16. What is the advantage of a linked list over an array?
- A.Better CPU cache performance overall
- B.Faster random access by index
- C.Dynamic size and efficient insertion✓ Correct
- D.Less memory usage per element
Explanation
Linked lists can grow or shrink dynamically and allow O(1) insertion/deletion at known positions without shifting elements.
Report an error in this question
Linear Data StructuresMedium
Q17. What is a sentinel node in a linked list?
- A.A dummy node to simplify boundary conditions✓ Correct
- B.The node containing the maximum data value
- C.A node that stores the total list size
- D.The last node in the list structure
Explanation
A sentinel (dummy) node is placed at the beginning or end of a linked list to simplify insertion and deletion by eliminating special cases for empty lists or boundary nodes.
Report an error in this question
Linear Data StructuresMedium
Q18. What is the condition for a circular queue being full (array implementation with size N)?
- A.front == 0 && rear == N - 1
- B.(rear + 1) % N == front✓ Correct
- C.rear == N - 1
- D.front == rear
Explanation
In a circular queue, the queue is full when the next position of rear equals front: (rear + 1) % N == front.
Report an error in this question
Linear Data StructuresMedium
Q19. What is the time complexity of searching for an element in an unsorted linked list?
- A.O(n^2)
- B.O(log n)
- C.O(1)
- D.O(n)✓ Correct
Explanation
In an unsorted linked list, you must traverse the list sequentially, taking O(n) in the worst case.
Report an error in this question
Linear Data StructuresMedium
Q20. Which application commonly uses a stack?
- A.Breadth-first graph search traversal
- B.Level-order tree traversal processing
- C.Function call management (call stack)✓ Correct
- D.Round-robin job scheduling system
Explanation
The system uses a call stack to manage function calls, storing return addresses and local variables for each active function.
Report an error in this question
Linear Data StructuresHard
Q21. What is the amortized time complexity of enqueue and dequeue operations when implementing a queue with two stacks?
- A.O(1) amortized for both✓ Correct
- B.O(1) enqueue, O(n) dequeue
- C.O(n) enqueue, O(1) dequeue
- D.O(n) for both operations
Explanation
Each element is pushed and popped at most twice (once from each stack), so the amortized cost per operation is O(1).
Report an error in this question
Linear Data StructuresHard
Q22. How can you detect a cycle in a linked list efficiently?
- A.By sorting the list nodes first in order
- B.By converting the list into an array form
- C.Using two nested loops over all nodes
- D.Using Floyd's tortoise and hare algorithm✓ Correct
Explanation
Floyd's algorithm uses two pointers moving at different speeds. If they meet, a cycle exists. It runs in O(n) time and O(1) space.
Report an error in this question
Linear Data StructuresHard
Q23. What is the time complexity of reversing a singly linked list iteratively?
- A.O(1)
- B.O(n^2)
- C.O(n)✓ Correct
- D.O(n log n)
Explanation
Reversing a singly linked list iteratively requires one pass through the list, taking O(n) time with O(1) extra space.
Report an error in this question
Linear Data StructuresHard
Q24. In a skip list, what is the expected time complexity of search?
- A.O(n)
- B.O(1)
- C.O(log n)✓ Correct
- D.O(n log n)
Explanation
A skip list uses multiple levels of linked lists with probabilistic balancing, providing O(log n) expected search time.
Report an error in this question
Linear Data StructuresHard
Q25. What is an XOR linked list?
- A.A circular linked list variant with XOR pointers
- B.A linked list that stores only odd-valued elements
- C.A linked list using XOR for data encryption purposes
- D.A doubly linked list using XOR of addresses to save memory✓ Correct
Explanation
An XOR linked list stores the XOR of the previous and next node addresses in a single pointer field, reducing memory usage compared to a standard doubly linked list.
Report an error in this question
Linear Data StructuresHard
Q26. How do you find the starting node of a cycle in a linked list using Floyd's algorithm?
- A.Use a hash table to store all visited node addresses
- B.Count all nodes in the list and compute the start
- C.Reset one pointer to head and move both one step✓ Correct
- D.Reverse the entire list and then detect the cycle
Explanation
After detecting the cycle, reset one pointer to head. Move both pointers one step at a time; the node where they meet is the cycle start.
Report an error in this question
Linear Data StructuresHard
Q27. What is the minimum number of stacks needed to implement a deque?
- A.1
- B.3
- C.2✓ Correct
- D.4
Explanation
A deque can be implemented using 2 stacks, where each stack handles one end of the deque.
Report an error in this question
Linear Data StructuresHard
Q28. What is the space overhead per node in a doubly linked list compared to a singly linked list?
- A.One extra data field
- B.No extra overhead
- C.Two extra pointers
- D.One extra pointer✓ Correct
Explanation
A doubly linked list node has one extra pointer (previous pointer) compared to a singly linked list node.
Report an error in this question
Linear Data StructuresHard
Q29. What is the time complexity of merging two sorted linked lists into one sorted list?
- A.O(n × m)
- B.O(n + m)✓ Correct
- C.O(n log m)
- D.O(n^2)
Explanation
Merging two sorted linked lists can be done in O(n + m) time by comparing heads and advancing pointers, where n and m are the lengths.
Report an error in this question
Linear Data StructuresHard
Q30. What is a self-organizing list?
- A.A list that reorders based on access patterns✓ Correct
- B.A list that balances itself like a tree structure
- C.A list that maintains sorted order automatically
- D.A list that automatically deletes duplicate items
Explanation
A self-organizing list rearranges its nodes based on access frequency or recency (e.g., move-to-front, transpose) to speed up future accesses.
Report an error in this question