This section covers the questions for the Linked List using JavaScript to clear all your concepts.
Question 1
Which of the following statements is correct about a singly linked list?
A singly linked list is a linear data structure with elements pointing to the next node.
A singly linked list stores elements in an array.
In a singly linked list, each node contains a reference to the previous node.
A singly linked list supports backward traversal without additional memory.
Question 2
In JavaScript, which of the following is the correct way to define a node for a singly linked list?
{data: 10, prevNode: null}
{nodeValue: 10, nextNode: null}
{value: 10, prevNode: null}
{value: 10, nextNode: null}
Question 3
Which method is used to traverse a singly linked list?
forEach()
map()
next()
while loop (traversing by moving from node to node)
Question 4
What happens if we try to access a node beyond the last node in a singly linked list?
An error will be thrown.
It will return null or undefined.
The program will crash.
It will result in an infinite loop.
Question 5
In a linked list, what is the time complexity for inserting a new node at the beginning?
O(1)
O(n)
O(log n)
O(n^2)
Question 6
Which of the following methods can be used to remove the last node in a singly linked list?
pop()
shift()
delete()
Traverse through the list and set the second-last node’s next pointer to null
Question 7
In a doubly linked list, each node contains:
Data and reference to the next node only.
Data and reference to both the next and previous node.
Only data.
Data, next node, and reference to the previous node, but in a single direction.
Question 8
How can you reverse a singly linked list?
By swapping the data of the nodes.
By deleting all nodes and creating a new list in reverse order.
By reversing the next pointers of the nodes.
By converting the linked list to an array and then reversing it.
Question 9
Which of the following is the correct way to check if a linked list has a loop?
Check if the last node points to null.
Traverse through the list and check if the node’s next points back to a previous node.
Check if the nodes contain references to themselves.
There is no way to check for a loop.
Question 10
What is the space complexity for storing a singly linked list with n nodes?
O(n)
O(1)
O(log n)
O(n^2)
There are 10 questions to complete.