Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Trace selection sort on the following array of letters (sort into alphabetical o

ID: 3575923 • Letter: T

Question

Trace selection sort on the following array of letters (sort into alphabetical order):

After each pass (outer loop iteration) of selection sort, show the contents of the array and the number of letter-to-letter comparisons performed on that pass (an exact number, not big-O).Trace insertion sort on the following array of letters (sort into alphabetical order):

After each pass (outer loop iteration) of insertion sort, show the contents of the array and the number of letter-to-letter comparisons performed on that pass (an exact number, not big-O).

Explanation / Answer

Selection sort goes like: Select the largest element and exchange it with the last element. Reduce the array size by 1, and keep doing the same.

So, given array is:

0 1 2 3 4 5 6 # of comparisons. Step 0 X A T B Q S B 0 Step 1 B A T B Q S X 6 Step 2 B A S B Q T X 5 Step 3 B A Q B S T X 4 Step 4 B A B Q S T X 3 Step 5 B A B Q S T X 2 Step 6 A B B Q S T X 1 Step 7 A B B Q S T X 0
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote