void fun(int a[],int n) { int j,i,k,m,mid; for(m = n/2;m>0;m/=2)…

0

void fun(int a[],int n)
{
int j,i,k,m,mid;
for(m = n/2;m>0;m/=2)
for(j = m;j=0;i-=m){
if(a[i+m]>=a[i])
break;
else{
mid = a[i];
a[i] = a[i+m];
a[i+m] = mid;
}
}
}
What is the worst case complexity of above code?
A) Θ(n^3)
B) Θ(n^2)
C) Θ(n^1.5)
D) Θ(n*lg(n))
Answer(C)

Ravi Garg edited question
    0
    Kapil Duhoon (anonymous)

    basically this is the code of shell short…

    Kapil Duhoon answered
      0
      Prashant Singh (anonymous)

      @Kapil Duhoon..

      please help me with this also

      Prashant Singh answered
        0
        Kapil Duhoon (anonymous)

        @Prashant Singh

        Check out the algorithm and compare it with the question :

        http://geeksquiz.com/shellsort/

        Kapil Duhoon answered
          Add image to editor add image from link

          Question stats

          • Active
          • Views361 times
          • Answers3 answers
          • Followers1 follower
          Question and answer is powered by AnsPress