Question 1
EasyWhat does each node of a singly linked list contain?
- A.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Data Structures and Algorithms
What does each node of a singly linked list contain?
Data and a pointer to the next node
Only data
An index
Data and pointers to both neighbours
Answer: A
The last node's next pointer is null.
What is the time complexity of inserting a node at the head of a singly linked list?
O(n)
O(log n)
O(1)
O(n²)
Answer: C
Point the new node at the old head and update the head pointer.
What is the time complexity of accessing the k-th element of a linked list?
O(log k)
O(1)
O(k)
O(n²)
Answer: C
There is no random access; you must follow k links from the head.
What is a doubly linked list?
A list with two heads
A list stored in an array
Two separate lists
A list whose nodes point to both the next and the previous node
Answer: D
It can be traversed in both directions and allows O(1) deletion of a known node.
What is a circular linked list?
A list sorted in a circle
A list with no nodes
A list whose last node points back to the first
A list shaped like a tree
Answer: C
It is useful for round-robin scheduling.
Which is an advantage of a linked list over an array?
Less memory per element
Faster random access
Better cache performance
Inserting and deleting at a known position doesn't require shifting elements
Answer: D
Arrays win on random access and cache locality.
What is the time complexity of searching for a value in an unsorted linked list?
O(n)
O(n log n)
O(1)
O(log n)
Answer: A
You may have to visit every node.
In a singly linked list, what does the last node's next pointer hold?
The previous node
NULL (None)
The head node
Its own address
Answer: B
A null pointer marks the end of the list.
What is the head of a linked list?
The last node
The largest value
A reference to the first node
The middle node
Answer: C
Traversal always starts from the head.
What is the time complexity of inserting at the end of a singly linked list when only the head pointer is kept?
O(n²)
O(log n)
O(n)
O(1)
Answer: C
You must walk from the head to the last node first.