Open In App

GATE | GATE CS 1999 | Question 59

Last Updated : 09 Oct, 2017
Improve
Improve
Like Article
Like
Save
Share
Report

[5 Marks question]

a.  Consider the following algorithm. Assume procedure A and procedure B take O(1) and O(1/n) unit of 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 of a singly linked list.


Answer:

Explanation:

Quiz of this Question
Please comment below if you find anything wrong in the above post


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads