What is a linked list?
A
A linear collection of data elements stored at contiguous memory locations
B
A linear collection of nodes connected by pointers
C
A tree-like data structure
D
A collection of unordered elements
Analysis & Theory
A linked list is a linear collection of nodes, where each node contains data and a reference (pointer) to the next node.
Which of these is an advantage of linked lists over arrays?
A
Random access of elements
B
Dynamic size and easy insertion/deletion
Analysis & Theory
Linked lists are dynamic and allow efficient insertion and deletion without shifting elements.
In a singly linked list, each node contains:
B
Data and pointer to the previous node
C
Data and pointer to the next node
Analysis & Theory
Each node has data and a pointer to the next node.
What does the 'head' of a linked list represent?
Analysis & Theory
The head is the reference to the first node in the linked list.
What is the time complexity to search for an element in a linked list?
Analysis & Theory
Searching requires traversing the list node by node, which takes O(n) time.
Which type of linked list allows traversal in both directions?
Analysis & Theory
Doubly linked lists have pointers to both the previous and next nodes.
How does a circular linked list differ from a regular linked list?
B
The last node points back to the head node
D
It uses arrays internally
Analysis & Theory
In a circular linked list, the last node’s next pointer points back to the head node.
Which operation is most efficient in a linked list compared to an array?
A
Accessing an element by index
B
Inserting at the beginning
Analysis & Theory
Inserting at the start of a linked list is O(1) and very efficient.
What does a node's 'next' pointer reference in the last node of a singly linked list?
Analysis & Theory
The last node’s 'next' pointer is set to null, indicating the end of the list.
What is the main disadvantage of linked lists compared to arrays?
B
They use more memory due to storing pointers
C
They are difficult to sort
D
They cannot be traversed
Analysis & Theory
Each node uses extra memory to store the pointer to the next (and possibly previous) node.