What are the worst-case and best-case running times of the following algorithm? for (i=1; i<=n; i++)                                                            __time {           if (a[i] > 0)                                                               ___time          {                     for(j=1;j<n; j*2)                                            ___time                                  c[i] = c[i]/b[i]; ___time }          else                    c[i] = b[i];                                                       ___time } Best case T(n)= Worst case T(n)=

icon
Related questions
Question

What are the worst-case and best-case running times of the following algorithm?

for (i=1; i<=n; i++)                                                            __time

{

          if (a[i] > 0)                                                               ___time

         {

                    for(j=1;j<n; j*2)                                            ___time

                                 c[i] = c[i]/b[i]; ___time

}

         else

                   c[i] = b[i];                                                       ___time

}

Best case T(n)=

Worst case T(n)=

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer