Figure 75 shows the best-case number of swaps for selection


Figure 7.5 shows the best-case number of swaps for Selection Sort as Θ(n). This is because the algorithm does not check to see if the ith record is already in the ith position; that is, it might perform unnecessary swaps.

(a) Modify the algorithm so that it does not make unnecessary swaps.

(b) What is your prediction regarding whether this modification actually improves the running time?

(c) Write two programs to compare the actual running times of the original Selection Sort and the modified algorithm. Which one is actually faster?

1000_16bf139b-35b6-429e-b832-bb158b9ee6d5.png

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Figure 75 shows the best-case number of swaps for selection
Reference No:- TGS01649261

Expected delivery within 24 Hours