Gate2017 ss Q48

0. Consider the following C function

  • Option : C
  • Explanation :
    for i = 1
    j will run from 1 to n by incrementing by '1' in each step 'j 'will run for n times
    For i=2
    j will run from 1 to n by incrementing by ‘2’ in each step j will run for n/2 times

    next time j will run for n/3 times
    and so on

    time complexity = n + n/2 + n/3 + n/4 + .....
    = n(1+1/2+1/3+.....)
    =nlogn
Cancel reply

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


Cancel reply

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