What is Innermost loop in imperfectly nested loops?

Lol I don’t know how to explain this so i’ll give it my best shot I recommend using a debugger! it may help you so much you won’t even know

for (i = 0; i < n; ++i)
{
   //Goes in here first.. i = 0..
   for (j = 0; j <= i - 1; ++j) {
        //Goes here second..
        //Goes inside here and gets stuck until j is greater then (i- 1) (right now i = 0)
        //So (i-1) = -1 so it does this only once.
        /*some statement*/
    p[i] = 1.0 / sqrt (x);
   }
   for (j = i + 1; j < n; ++j)
   {
      //Goes sixth here.. etc.. .. 
      //when this is done.. goes to loop for (i = 0; i < n; ++i)

      //Goes here third and gets stuck
      //j = i which is 0 + 1.. so, j == 1
      //keeps looping inside this loop until j is greater then n.. idk what is n..
      //Can stay here until it hits n.. which could be a while.
       x = a[i][j];
       for (k = 0; k <= i - 1; ++k) {
           //Goes in here fourth until k > (i-1).. i is still 0..
           //So (i-1) = -1 so it does this only once
          /*some statement*/
       a[j][i] = x * p[i];
      }
      //Goes here fifth.. which goes.... to this same loop!
   }
}

Leave a Comment