Question 71
HardIn a doubly linked list, how many pointer assignments does inserting a node between two existing nodes need?
- A.
1
- B.
6
- C.
2
- D.
4
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Data Structures and Algorithms
In a doubly linked list, how many pointer assignments does inserting a node between two existing nodes need?
1
6
2
4
Sign up free to see the answer and a step-by-step explanation.
What is a skip list?
A linked list with extra express lanes of pointers, giving O(log n) expected search
A doubly linked list
A list with deleted nodes
A circular list
Sign up free to see the answer and a step-by-step explanation.
What does an XOR linked list store in each node?
The XOR of the previous and next node addresses
A hash
Two separate pointers
Only the next address
Sign up free to see the answer and a step-by-step explanation.
Which operation is O(1) on a singly linked list with both head and tail pointers?
Deleting the tail
Accessing the k-th node
Finding the middle
Appending at the tail
Sign up free to see the answer and a step-by-step explanation.
How can you delete a node from a singly linked list given only a pointer to it (not the last node)?
Copy the next node's value into it and unlink the next node
It is impossible
Traverse from the head always
Set it to None
Sign up free to see the answer and a step-by-step explanation.
What is the time complexity of finding the middle of a linked list with slow and fast pointers?
O(1)
O(log n)
O(n)
O(n²)
Sign up free to see the answer and a step-by-step explanation.
Which structure combines a hash map and a doubly linked list?
A trie
A segment tree
An LRU cache
A binary heap
Sign up free to see the answer and a step-by-step explanation.
What happens if you reverse a linked list that contains a cycle without checking for it?
It works normally
It raises an error automatically
Only the cycle is reversed
The loop never ends (or the list is corrupted)
Sign up free to see the answer and a step-by-step explanation.
Why are linked lists slower than arrays for sequential traversal in practice, even though both are O(n)?
Nodes are scattered in memory, so they make poor use of the CPU cache
They are not slower
Linked lists have more elements
Arrays are compressed
Sign up free to see the answer and a step-by-step explanation.
How do you remove duplicate values from an unsorted singly linked list in O(n) expected time?
Sort the list first
Reverse the list
Keep a hash set of values seen so far and unlink any node whose value is already in it
Compare every pair of nodes
Sign up free to see the answer and a step-by-step explanation.