This is the array that needs to be sorted in ascending order:
Address |
Value |
a0 |
8 |
a1 |
7 |
a2 |
6 |
a3 |
2 |
a4 |
9 |
There will be three scenarios:
Either a0 = a1 or a0 > a1 or a0 < a1
It appears there will be a swap from a0 to a1 as a0 > a1.
One way to do swap I have earlier came across is:
a0 = at
at = a1
a1 = at
Will the above process be applicable also here.
Also, how to have at? Can a new address at be created initially holding say 0?
Reply
Yes it’s applicable.
tmp = A[0];
A[0] = A[1];
A[1] = tmp;
[learn_press_profile]