...
Nielit Scientist-C 2016 march
October 26, 2023
GATE 2011
October 26, 2023
Nielit Scientist-C 2016 march
October 26, 2023
GATE 2011
October 26, 2023

Algorithms

Question 16

(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.

A
Theory Explanation.
Correct Answer: A

Leave a Reply

Your email address will not be published. Required fields are marked *