Write this code without hesitation:
/* n: Array length for (i = 1 ; i < N; I++ int t = I; while (T > 0 ? a[t]<a[t-< Span style= "color: #800080;" >1 ]:) { int k = a[t]; A[t] = a[t-1 ]; A[t -1 ] = K; T = t-1 ; }}
The elements in the original a[i] have been found, if the order is correct, as compared to the previous one. A[0..I-1] elements are ordered, which is called "cyclic invariant" in the book.
Also: can expressions in a while loop be written as "T > 0 && a[t] < a[t-1]"? Is it likely that an access is out of bounds? Please also give directions.
The pseudo-code given in the book is written as follows:
for 1; i < N; i++) { int1; while 0 && a[j] > t) { 1] = a[j]; J--; } 1] = t;}
There is no obvious exchange, in fact, and "Find out a[i" should be in the position a[k], will a[k+1..i-1] elements of the back one "is the same principle, but the book is clearly a lot of concise.
Introduction to Algorithms Learning Notes: 2.1-inserting sort