Question: In Java Convince yourself that the following code fragment rearranges the integers stored in the variables A, B, C, and D so that A B)
In Java
Convince yourself that the following code fragment rearranges the integers stored in the variables A, B, C, and D so that A <= B <= C <= D.
if (A > B) { t = A; A = B; B = t; } if (B > C) { t = B; B = C; C = t; } if (A > B) { t = A; A = B; B = t; } if (C > D) { t = C; C = D; D = t; } if (B > C) { t = B; B = C; C = t; } if (A > B) { t = A; A = B; B = t; } if (D > E) { t = D; D = E; E = t; } if (C > D) { t = C; C = D; D = t; } if (B > C) { t = B; B = C; C = t; } if (A > B) { t = A; A = B; B = t; } |
Optimal oblivious sorting networks. Create a program that
sorts 4 integers using only 5 if statements,
and one that sorts 5 integers using only 9 if statements of the type above?
and one that sorts 6 integers using only 12 if statements of the type above
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
