(a) Consider the following algorithm. Assume procedures A and B take O(1) and…
PYQ GATE 1999
(a) Consider the following algorithm. Assume procedures A and B take O(1) and O(1/n) time, respectively. Derive the time complexity of the algorithm in O-notation.
algorithm what(n)
begin
if n = 1 then call A
else begin
what(n - 1);
call B(n)
end
end.(b) Write a constant-time algorithm to insert a node with data D just before the node with address p in a singly linked list.
Sign up free to check your answer
Sign up freeLoading lesson…

