Skip to content
Related Articles

Related Articles

GATE | GATE CS 1999 | Question 59

View Discussion
Improve Article
Save Article
  • Last Updated : 09 Oct, 2017
View Discussion
Improve Article
Save Article

[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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!