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

[1] Find the number of comparisons needed when we apply Selection Sort to sort 1

ID: 3586308 • Letter: #

Question

      [1] Find the number of comparisons needed when we apply Selection Sort to sort 100

            distinct integers.

      [2] Find the number of comparisons needed when we apply Selection Sort to sort n

            distinct integers.

      [3] Find the number of comparisons needed when we apply Selection Sort to sort n

             distinct integers which are arranged in increasing order.

       [4] Find the number of comparisons needed when we apply Selection Sort to sort n

             distinct integers which are arranged in decreasing order.

Explanation / Answer

for selection sort no. of comparisons are like (n-1)+(n-2)+(n-3)+..... i.e n(n-1)/2
PART 1 for sorting 100 distinct integer total no. of comparison required are 100(99)/2 = 4950
PART 2 for sorting n distinct integers tataol no. of comparisons required are n*(n-1)/2
PART 3 for sorted n distinct integers which are arranged in increasing order n*(n-1)/2 irrespective of the order all no.s and comparison are done
PART 4 for sorted n distinct integers which are arranged in decreasing order n*(n-1)/2

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