Q. In a doubly linked list, how do you delete a node given only a pointer to that node?
-
A.
Set next and previous pointers
-
B.
Traverse from head
-
C.
Use a stack
-
D.
Not possible
Solution
In a doubly linked list, you can delete a node by adjusting the next and previous pointers of the adjacent nodes.
Correct Answer:
A
— Set next and previous pointers
Learn More →
Q. What is the average time complexity of quicksort?
-
A.
O(n)
-
B.
O(n log n)
-
C.
O(n^2)
-
D.
O(log n)
Solution
The average time complexity of quicksort is O(n log n), making it efficient for large datasets.
Correct Answer:
B
— O(n log n)
Learn More →
Q. What is the space complexity of a recursive function that uses O(n) stack space?
-
A.
O(1)
-
B.
O(n)
-
C.
O(n^2)
-
D.
O(log n)
Solution
The space complexity of a recursive function that uses O(n) stack space is O(n) due to the call stack.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of deleting the last node in a singly linked list?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n log n)
Solution
To delete the last node in a singly linked list, you must traverse the list to find the second-to-last node, resulting in O(n) time complexity.
Correct Answer:
B
— O(n)
Learn More →
Showing 1 to 4 of 4 (1 Pages)