What is a linked list?
A) A collection of elements stored in contiguous memory locations
B) A data structure consisting of nodes where each node contains a data field and a reference to the next node
C) A static data structure
D) An array with pointers
Answer: B) A data structure consisting of nodes where each node contains a data field and a reference to the next node
What is the time complexity for accessing an element in a linked list?
A) O(1)
B) O(n)
C) O(log n)
D) O(n log n)
Answer: B) O(n)
Which of the following operations can be performed on a linked list?
A) Insertion
B) Deletion
C) Traversal
D) All of the above
Answer: D) All of the above
What is the main advantage of using a linked list over an array?
A) Fixed size
B) Random access
C) Dynamic sizing
D) Simpler implementation
Answer: C) Dynamic sizing
In a singly linked list, what does the last node point to?
A) The first node
B) The previous node
C) NULL
D) The next node
Answer: C) NULL
What is a doubly linked list?
A) A list where each node has only one pointer
B) A list where each node has two pointers, one to the next and one to the previous node
C) A list that can only store integer values
D) A circular linked list
Answer: B) A list where each node has two pointers, one to the next and one to the previous node
What is the time complexity for inserting a node at the beginning of a linked list?
A) O(1)
B) O(n)
C) O(log n)
D) O(n log n)
Answer: A) O(1)
Which of the following is true about circular linked lists?
A) The last node points to NULL
B) There is no start or end
C) They can only be singly linked
D) They require more memory
Answer: B) There is no start or end
How do you traverse a singly linked list?
A) Using a loop and a pointer
B) Using recursion
C) Both A and B
D) None of the above
Answer: C) Both A and B
What happens if you try to access the next pointer of a NULL node?
A) It returns zero
B) It causes a segmentation fault
C) It returns NULL
D) It creates a new node
Answer: B) It causes a segmentation fault
What is the time complexity of deleting a node from a linked list?
A) O(1)
B) O(n)
C) O(log n)
D) O(n log n)
Answer: B) O(n)
Which of the following is NOT a type of linked list?
A) Singly linked list
B) Doubly linked list
C) Circular linked list
D) Multi-linked list
Answer: D) Multi-linked list
What is the primary disadvantage of a linked list?
A) Dynamic size
B) More memory usage due to pointers
C) Easier insertion and deletion
D) Sequential access
Answer: B) More memory usage due to pointers
What is the purpose of the head pointer in a linked list?
A) To store the last element
B) To track the number of nodes
C) To point to the first node
D) To allow for dynamic resizing
Answer: C) To point to the first node
What is the output of the following code? ListNode head = NULL; head->next = new ListNode(5);*
A) 5
B) NULL
C) Segmentation fault
D) 0
Answer: C) Segmentation fault
What is the process of reversing a linked list?
A) Changing the order of the nodes
B) Changing the data in each node
C) Deleting the nodes and creating new ones
D) None of the above
Answer: A) Changing the order of the nodes
In a doubly linked list, what does the previous pointer of the first node point to?
A) NULL
B) The last node
C) The second node
D) It depends on the implementation
Answer: A) NULL
What is a sentinel node in a linked list?
A) A special node used to mark the end of the list
B) A node with no data
C) A node that points to itself
D) A node used to simplify insertion and deletion
Answer: D) A node used to simplify insertion and deletion
What is the best way to find a node in a linked list?
A) Iterate through the list
B) Use a binary search
C) Use a hash table
D) It cannot be done
Answer: A) Iterate through the list
What is the effect of deleting the head node of a linked list?
A) The list is unchanged
B) The head pointer must be updated
C) It causes a memory leak
D) The list becomes circular
Answer: B) The head pointer must be updated
What is the output of the following code? int arr[5]; arr[5] = 10;
A) 10
B) Undefined behavior
C) 0
D) Compilation error
Answer: B) Undefined behavior
Which data structure can be used to implement a stack?
A) Array only
B) Linked list only
C) Both arrays and linked lists
D) None of the above
Answer: C) Both arrays and linked lists
What is the main reason for using a linked list over an array in some cases?
A) Faster access time
B) Fixed size
C) Easier insertion and deletion
D) Less memory usage
Answer: C) Easier insertion and deletion
What is the process of finding the middle node in a linked list called?
A) Traversal
B) Midpoint search
C) Fast-slow pointer technique
D) Bisection
Answer: C) Fast-slow pointer technique
Which of the following operations is most expensive in a linked list?
A) Insertion
B) Deletion
C) Accessing elements
D) Traversal
Answer: C) Accessing elements
What happens to the linked list when the last node is deleted?
A) The head pointer is set to NULL
B) The list remains unchanged
C) A new node is created
D) The list becomes circular
Answer: A) The head pointer is set to NULL
What is the primary characteristic of a circular doubly linked list?
A) Nodes point only to the next node
B) The last node points to the first node and the first node points to the last node
C) Nodes contain no data
D) It requires more memory than a regular linked list
Answer: B) The last node points to the first node and the first node points to the last node
What is a common application of linked lists?
A) Implementing stacks and queues
B) Storing data in arrays
C) Representing graphs
D) All of the above
Answer: A) Implementing stacks and queues
How do you delete a node from the middle of a linked list?
A) Change the data of the previous node
B) Point the previous node to the next node
C) Point the next node to the previous node
D) Both A and B
Answer: B) Point the previous node to the next node
What is the time complexity for finding the length of a linked list?
A) O(1)
B) O(n)
C) O(log n)
D) O(n log n)
Answer: B) O(n)
Which pointer is used to traverse a linked list?
A) Head pointer
B) Tail pointer
C) Current pointer
D) All of the above
Answer: A) Head pointer
What is the effect of using delete
on a node in a linked list?
A) It frees the memory allocated for the node
B) It only removes the data
C) It causes a memory leak
D) It does nothing
Answer: A) It frees the memory allocated for the node
What type of linked list has nodes pointing to the next node as well as the previous node?
A) Singly linked list
B) Circular linked list
C) Doubly linked list
D) None of the above
Answer: C) Doubly linked list
What is the time complexity for inserting a node at the end of a linked list?
A) O(1) if you maintain a tail pointer
B) O(n)
C) O(log n)
D) O(n log n)
Answer: A) O(1) if you maintain a tail pointer
Which of the following is NOT a characteristic of linked lists?
A) Dynamic size
B) Nodes contain pointers
C) Random access
D) Sequential access
Answer: C) Random access
How can you implement a queue using linked lists?
A) By using two pointers
B) By using one pointer
C) By using an array
D) It cannot be done
Answer: A) By using two pointers
Basic Concepts
Non-Linear Data Structures MCQs
Sorting and Searching Algorithms MCQs
- Data Structures MCQs 1
- Data Structures MCQs 2
- Data Structures MCQs 3
- Data Structures MCQs 4
- Data Structures MCQs 5
- Stacks Solved MCQs
- Queues MCQs
- pointer mcqs
- Array MCQs