Question

Selection Sort

03 Nov 2017
Answer :
Word Count : 748

Once again, here are the formulas we derived for the number of comparisons and swaps the Selection Sort requires in the worst case. The number of items to be sorted is represented by n.

# of swaps = (n-1)

# of comparisons = (n-1) + (n-2) + ... + 1

Notice that the formula for the number of comparisons is a summation, a series of terms added together. Each term represents the comparisons from one step of our sort. As we increase the number of items to be sorted, we also increase the number of terms in our formula. For example, suppose we were sorting six items and we wanted to know the maximum number of comparisons needed to sort them (i.e. the worst case). Here is how we would find the answer.

First, we write out the correct number of terms in our formula. Remember that n = 6 in this example. The last term in our formula is (n - 5) because this is equal to 1.

# of comparisons = (n-1) + (n-2) + (n-3) + (n-4) + (n-5)

Now we substitute 6 for n and sum the values.

# of comparisons = (6-1) + (6-2) + (6-3) +

__________ ______ ___ ________ ____ ______ __________ ______ ___ _____ ______.
_______ ___ ________ __________ ____ _____ ______ ______ ________ __________ _____ ___.
____ __________ ____ _________ ________ _____ _______ ________ ______ ____ _____ _____.
__________ _______ _____ _________ _________.
__________ ____ ____ ____ ____ _________ _____ ________ ______.
____ _________ _____ ______ ______ _______ ______ ___.
_____ ______ _________ _______ __________.
_________ ________ ________ _________ ___ ______ ____ _________ ______ __________.
_______ __________ ___ ____ ___ ____ ________.
_________ _______ ____ ____ ____ ____ ____ _____ ______ __________.
_______ _______ _________ ______ ____ _______ _____ _____ __________.
_______ _____ ______ _________ ______ __________ ____ ________ __________ ______ ________.
______ ________ ________ _____ _________ ________ ________ _____ __________ _________.
____ ___ ______ ________ ________ ______ _____.
___ _________ ________ _____ ___.
_______ ________ ______ __________ ______ _______ ______ _____ ___ __________.
_________ ____ ________ ______ ____ ______.
_______ _________ ______ ______ ____ ____ _________ ___ _____ _____ _______.
___ _______ ____ ____ ____ _________ ________.
__________ ________ ________ ______ _______ ________ _______ __________ ____ ______.
_______ ________ ____ ______ _______ _________ ______ _____ ________ ________.
___ ____ ________ __________ ______ _______ ___ _________ ________ _____.
________ _____ _____ ___ _______ ____ ________ ______.
_____ _____ _________ _____ _________ ____ ______.
__________ ______ ____ __________ ________ ________ _________ ___ _______ ________ __________.
____ _____ _____ ______ _____ __________ ___ ______ __________.
____ _______ _________ ______ ________ _____ ________ _____.
__________ ___ ______ ____ _______ __________ ________.
______ ___ ____ _____ _________ ____ _____ _____ ___.
____ _________ _______ ____ _______ ___ ________ __________ _________ ________.
________ __________ _________ _____ ______ _________ ________ __________.
_________ __________ _____ _________ ______ _______ __________ __________ ____.
____ _______ _________ _________ ____ _____ _____.
___ ______ ____ _________ __________ __________ ___ ___ ____ ________ __________ ___.
_____ ______ _____ ___ _______.
___ _____ ________ ________ _________ ______ _________ _____ ___ ________ ________.
_________ ___ ________ ____ _____ ________.
_____ ____ _______ ______ ______ ______ ______ __________ __________ ____ _______.
_______ ________ ________ _____ ________ ________ ______ _________ ______ ______.
______ __________ _____ _____ ________ __________ ________ ______ ______ _______ ____ ___.
____ _____ _______ _______ ____ _________ ___.
____ _______ _____ _______ _____ _________ _______ ______ _______ _____ _____ ___.
________ _________ ____ ____ _______ ___.
______ _________ _______ ___ _______ _______ ___ __________ _____ ___ __________.
___ ______ _________ _____ _____ ______ _____ __________ ___ ___ ______ _______.
__________ _______ ____ ________ ______.
_____ ___ ____ _____ ___ ________ _____ __________ ________.
___ ____ _______ _______ ____ ________ ____ ____.
_______ _____ _____ _____ ________ __________ ______ ____.
_______ ___ _________ ____ ___ ___.
________ _________ _____ __________ ____ __________ ___ __________.
_____ ________ _________ __________ _______ ________ __________ __________.
___ ______ ___ ____ _____ _____.
________ ___ _____ ___ ______ ___ ___ ____ ________.
_____ _____ _____ __________ __________ ______ __________ ___ __________.
_______ __________ ___ ____ ________ _____ ____ __________ ______ ________ _________.
_____ __________ _________ ______ ________.
________ ________ ________ ____ _____ _____ _______ ________ _________ ______ ___ _________.
___ _______ ____ _________ ______ ________ ____ ______ __________ _________ _______ _________.
_____ __________ ____ _________ ____ ___ ____ _____ _______.
_______ __________ _______ ____ _______ _______.
_________ ___ ______ ________ __________ _______.
_____ ___ __________ ____ ______ _________.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MCS 31 2011 - Selection Sort | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→