Original table    Properties

 

 

  Each day, all of her flowers grow taller than they were the day before.




  

Original table    Properties

 

 

  .... first row recording the shortest sunflower's growth and 
  the last row recording the tallest sunflower's growth

  If a sunflower was smaller than another when initially planted, 
  it remains smaller for every measurement.
  

Original table    Properties

 

 

  Key:

      The smallest value is originally in the upper-left corner !


  

Final table    Properties

 

  The final table can be in

        one of 4 possible states

  Each state can be idenitified by the location of the smallest value !!

Final table    Properties

 

  The final table can be mapped back to the original table by:

        reading the columns and rows in a specific order !

  

Final table    Properties

 

  Case 1: (a[0][0] is smallest value)

      for ( i = 0; i < N; i++ )
         for ( k = 0; k < N; k++ )
            cout << grid[i][k];

Final table    Properties

 

  Case 2: (a[0][N-1] is smallest value)

      for ( i = N-1; i >= 0; i-- )
         for ( k = 0; k < N; k++ )
            cout << a[k][i] 

Final table    Properties

 

  Case 3: (a[N-1][N-1] is smallest value)

      for ( i = N-1; i >= 0; i-- )
         for ( k = N-1; k >= 0; k-- )
            cout << a[i][k] 

Final table    Properties

 

  Case 4: (a[N-1][0] is smallest value)

      for ( i = 0; i < N; i++ )
         for ( k = N-1; k >= 0; k-- )
            cout << a[k][i] 

J4 solution    In C++
   /* --------------------------
      Determine configuration
      -------------------------- */
   int min, iMin, kMin;

   iMin = 0; kMin = 0;   // Assume grid[0][0] is min
   min = grid[0][0];

   if ( grid[0][N-1] < min )
   {
      iMin = 0; kMin = N-1; min = grid[0][N-1];
   };

   if ( grid[N-1][N-1] < min )
   {
      iMin = N-1; kMin = N-1; min = grid[N-1][N-1];
   };
   if ( grid[N-1][0] < min )
   {
      iMin = N-1; kMin = 0; min = grid[N-1][0];
   };

   /* --------------------------------------
      Print grid according to configuration
      -------------------------------------- */
   if ( iMin == 0 && kMin == 0 )
   {
      ... (see explanation in previous pages)
   }

   etc