Figure 7.5 shows the best-case number of swaps for Selection Sort as (n). This is because the
Question:
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?
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Practical Introduction To Data Structures And Algorithm Analysis Java Edition
ISBN: 9780136609117
1st Edition
Authors: Clifford A. Shaffer
Question Posted: