Question: Sorting three numbers. Suppose that the variables a, b, c, and t are all of the type int. Explain why the following code puts a,
Sorting three numbers. Suppose that the variables a, b, c, and t are all of the type int. Explain why the following code puts a, b, and c in ascending order:
if (a > b) { t = a; a = b; b = t; }
if (a > c) { t = a; a = c; c = t; }
if (b > c) { t = b; b = c; c = t; }
Step by Step Solution
3.43 Rating (153 Votes )
There are 3 Steps involved in it
This code fragment is using whats known as a bubble sort algorithm Its a simple sorting algorithm th... View full answer
Get step-by-step solutions from verified subject matter experts
