Number given: 7 3 1 2 5
S1: Take the largest number from the list and place it on the last.
3 1 2 5 / 7
S2: Take the largest number from the remain numbers and place it before the previous selected number.
3 1 2 / 5 7
S3: Take the largest number from the remain numbers and place it before the previous selected number.
1 2 / 3 5 7
S4: Take the largest number from the remain numbers and place it before the previous selected number.
1 / 2 3 5 7
S5: Take the largest number from the remain numbers and place it before the previous selected number.
1 2 3 5 7
1 2 3 5 7 is the end product. End product is in ascending order.

没有评论:
发表评论