Linked Lists (Singly, Doubly, Circular) # MCQs Practice set

Q.1 Which of the following is true about a singly linked list?

Each node points to its previous node
Each node points to its next node only
Each node points to both next and previous nodes
The last node points to the first node
Explanation - In a singly linked list, each node contains data and a pointer to the next node. There is no backward link.
Correct answer is: Each node points to its next node only

Q.2 What is the main advantage of a doubly linked list over a singly linked list?

Less memory usage
Can traverse in both directions
Simpler insertion at the beginning
No advantage at all
Explanation - Doubly linked lists have pointers to both the next and previous nodes, allowing bidirectional traversal.
Correct answer is: Can traverse in both directions

Q.3 In a circular linked list, how is the last node connected?

It points to NULL
It points to the first node
It points to the previous node
It points to itself only
Explanation - Circular linked lists connect the last node back to the first node to form a circle.
Correct answer is: It points to the first node

Q.4 Which operation is typically faster in a doubly linked list than in a singly linked list?

Traversal from the head to tail
Insertion after a known node
Deletion of a known node given a pointer to it
Insertion at the end without a tail pointer
Explanation - In a doubly linked list, deletion of a node is faster because you can access the previous node directly.
Correct answer is: Deletion of a known node given a pointer to it

Q.5 What is the worst-case time complexity for searching an element in a singly linked list?

O(1)
O(log n)
O(n)
O(n^2)
Explanation - Singly linked lists require sequential traversal for searching, which is linear in time complexity.
Correct answer is: O(n)

Q.6 Which of the following is a disadvantage of linked lists compared to arrays?

Dynamic memory allocation
Inefficient random access
Easy insertion and deletion
No memory wastage
Explanation - Linked lists cannot provide direct access to elements via indices, unlike arrays.
Correct answer is: Inefficient random access

Q.7 Inserting a node at the beginning of a singly linked list has a time complexity of:

O(n)
O(log n)
O(1)
O(n^2)
Explanation - Insertion at the head involves changing the head pointer and the new node's next pointer, which is constant time.
Correct answer is: O(1)

Q.8 Which of the following is true about circular doubly linked lists?

They have only one pointer per node
They cannot be traversed backwards
The last node points to the first, and vice versa
They are always sorted
Explanation - Circular doubly linked lists connect the last node to the first node and maintain backward links as well.
Correct answer is: The last node points to the first, and vice versa

Q.9 What is the space complexity of a doubly linked list with n nodes?

O(n)
O(n^2)
O(1)
O(log n)
Explanation - Each node contains data and two pointers, but the overall space grows linearly with the number of nodes.
Correct answer is: O(n)

Q.10 Which of the following is the correct way to free memory of a node in C?

delete node;
free(node);
remove(node);
node = NULL;
Explanation - In C, dynamically allocated memory is released using the free() function.
Correct answer is: free(node);

Q.11 If a singly linked list has a cycle, which algorithm can detect it efficiently?

Binary search
Floyd’s cycle-finding algorithm
Merge sort
Breadth-first search
Explanation - Floyd’s algorithm, also called the tortoise and hare algorithm, detects cycles using two pointers moving at different speeds.
Correct answer is: Floyd’s cycle-finding algorithm

Q.12 Which of the following is true for deleting the last node in a singly linked list?

Only head pointer needs to be updated
We need to traverse to the second last node
It can be done in O(1) without traversal
It is impossible
Explanation - In a singly linked list, we must access the node before the last to update its next pointer to NULL.
Correct answer is: We need to traverse to the second last node

Q.13 Which linked list type is most suitable for implementing a queue?

Singly linked list
Doubly linked list
Circular linked list
None of the above
Explanation - A queue can be efficiently implemented using a singly linked list with head and tail pointers.
Correct answer is: Singly linked list

Q.14 In a doubly linked list, how do you insert a new node after a given node?

Change only the new node's next pointer
Update new node's next and prev, and adjacent nodes
Delete the given node first
Traverse the entire list from head
Explanation - Insertion requires adjusting the new node's pointers and the surrounding nodes’ pointers.
Correct answer is: Update new node's next and prev, and adjacent nodes

Q.15 Which type of linked list can efficiently implement a circular buffer?

Singly linked list
Doubly linked list
Circular linked list
Stack
Explanation - Circular linked lists naturally wrap around, making them ideal for circular buffers.
Correct answer is: Circular linked list

Q.16 Inserting at the end of a singly linked list without a tail pointer requires:

O(1) time
O(n) time
O(log n) time
O(n^2) time
Explanation - Without a tail pointer, we need to traverse the entire list to reach the last node.
Correct answer is: O(n) time

Q.17 Which of the following is a real-world use of a doubly linked list?

Undo functionality in text editors
Queue for printers
Stack implementation
Hash table chaining
Explanation - Doubly linked lists allow backward and forward traversal, which is useful for undo/redo operations.
Correct answer is: Undo functionality in text editors

Q.18 Which operation is more memory-intensive?

Singly linked list
Doubly linked list
Array
Stack
Explanation - Doubly linked lists store two pointers per node, using more memory than singly linked lists.
Correct answer is: Doubly linked list

Q.19 What happens if you delete a node in a doubly linked list but forget to update the previous node’s next pointer?

The list remains intact
Memory leak may occur and list may break
The deleted node becomes head
The list converts to singly linked list
Explanation - Pointers must be properly updated to maintain the list structure; otherwise, links are broken and memory may be lost.
Correct answer is: Memory leak may occur and list may break

Q.20 Which of the following best describes a circular singly linked list?

The last node points to NULL
The last node points to the first node
Each node has two pointers
It has a tail pointer only
Explanation - In a circular singly linked list, the last node points back to the first node, forming a circle.
Correct answer is: The last node points to the first node

Q.21 Which of the following is true about the head pointer in a linked list?

It always points to NULL
It points to the first node
It points to the last node
It is optional
Explanation - The head pointer keeps track of the first node in the list.
Correct answer is: It points to the first node

Q.22 Which operation is easiest to perform in a circular linked list compared to a singly linked list?

Traversal from head to tail
Repeatedly visiting all nodes in a loop
Insertion at head
Deletion of head node
Explanation - Circular lists allow continuous traversal without checking for NULL, which is useful in round-robin scenarios.
Correct answer is: Repeatedly visiting all nodes in a loop

Q.23 How can a memory-efficient doubly linked list be implemented?

By storing XOR of next and previous pointers
By using arrays instead
By not storing data
By using circular references
Explanation - XOR linked lists use bitwise XOR to store a single pointer for both next and previous nodes, saving memory.
Correct answer is: By storing XOR of next and previous pointers

Q.24 Which of the following is true for deletion of a node in a circular linked list?

Always O(1) time
Requires traversal to the node or its previous node
Cannot delete the last node
Only the head can be deleted
Explanation - To delete a node, we must know its previous node to update pointers correctly, even in circular lists.
Correct answer is: Requires traversal to the node or its previous node

Q.25 What is the primary reason to use a linked list over an array?

Faster access by index
Efficient dynamic memory usage and easy insertion/deletion
Uses less memory always
Simpler data structure
Explanation - Linked lists allow dynamic allocation and easy insertion/deletion without shifting elements, unlike arrays.
Correct answer is: Efficient dynamic memory usage and easy insertion/deletion