better rendering of example steps

This commit is contained in:
Krishna Vedala 2020-07-01 10:36:08 -04:00
parent 9b799c93cb
commit 69b5c8395a
No known key found for this signature in database
GPG Key ID: BA19ACF8FC8792F7

View File

@ -23,20 +23,20 @@
* of elements as soon as we find a unsorted element that is a misplaced
* element we place it at a sorted position.
*
* Execution example steps:
* Example execution steps:
* 1. Suppose initially we have
* <pre>4 3 2 5 1</pre>
* \f{bmatrix}{4 &3 &2 &5 &1\f}
* 2. We start traversing from 4 till we reach 1
* when we reach at 3 we find that it is misplaced so we take 3 and place
* it at a correct position thus the array will become
* <pre>3 4 2 5 1</pre>
* \f{bmatrix}{3 &4 &2 &5 &1\f}
* 3. In the next iteration we are at 2 we find that this is also misplaced so
* we place it at the correct sorted position thus the array in this iteration
* becomes
* <pre>2 3 4 5 1</pre>
* \f{bmatrix}{2 &3 &4 &5 &1\f}
* 4. we does not do anything with 5 and move on to the next iteration and
* select 1 which is misplaced and place it at correct position. Thus, we have
* <pre>1 2 3 4 5</pre>
* \f{bmatrix}{1 &2 &3 &4 &5\f}
*/
#include <algorithm>