Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 10

SELECTION

SORT
Group 2
SELECTION SORT 2

DESCRIPTION
• This sorting algorithm is an in-place comparison- based algorithm.

•in which the list is divided into two parts, the sorted part at the left end and the
unsorted part at the right end.

•Initially, the sorted part is empty and the unsorted part is the entire list.

•The smallest element is selected from the unsorted array and swapped with the
leftmost element, and that element becomes a part of the sorted array.

• This process continues moving unsorted array boundary by one element to the right

• each time selecting an item according to its ordering and placing it in the correct
position in the sequence.
Presentation title 3

THE SELECTION
SORT ALGORITHM
• For each index position i

• Find the smallest data value in the array from positions i through length-1, where
length is the number of data values stored.

• Exchange (swap) the smallest value with the value at position i.


4

ALGORITHM
• Step 1 Set MIN to location o

• Step 2 Search the minimum element in the list

• Step 3- Swap with value at location MIN

• Step 4 Increment MIN to point to next element

• Step 5- Repeat until list is sorted


5

EXAMPLE
6

EXAMPLE
7

EXAMPLE
8

EXAMPLE
9

ADVANTAGES

• The main advantage of the selection sort is that it performs well on a small list.

• no additional temporary storage is required.


10

DISADVANTAGES

• The primary disadvantage of the selection sort is its poor efficiency when dealing
with a huge list of items.

• the selection sort requires n- squared number of steps for sorting n elements.

You might also like