0% found this document useful (0 votes)
835 views

Sorting 10 Activity 1

The document compares different sorting algorithms - bubble sort, selection sort, insertion sort, and merge sort - by showing the steps and results of sorting the same sample data using each algorithm. Bubble sort involves repeatedly swapping adjacent elements if they are in the wrong order until fully sorted. Selection sort finds the minimum element and swaps it into the correct position each iteration. Insertion sort inserts elements into the correct position in the sorted portion of the array. Merge sort recursively divides the array into halves and then merges the sorted halves.

Uploaded by

Sock the Cat
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
835 views

Sorting 10 Activity 1

The document compares different sorting algorithms - bubble sort, selection sort, insertion sort, and merge sort - by showing the steps and results of sorting the same sample data using each algorithm. Bubble sort involves repeatedly swapping adjacent elements if they are in the wrong order until fully sorted. Selection sort finds the minimum element and swaps it into the correct position each iteration. Insertion sort inserts elements into the correct position in the sorted portion of the array. Merge sort recursively divides the array into halves and then merges the sorted halves.

Uploaded by

Sock the Cat
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Bubble sort

21 4 25 16 4 21 25 16

4 21 25 16 4 21 25 16

4 21 25 16 4 21 16 25
4 21 16 25
4 21 16 25
4 16 21 25
4 21 16 25

Selection sort

21 4 25 16 12 17 4 21 25 16 12 17
4 21 25 16 12 17 4 12 25 16 21 17
4 12 25 16 21 17 4 12 16 25 21 17
4 12 16 25 21 17 4 12 16 17 21 25
Insertion sort

21 4 25 16 12 4 21 25 16 12
4 21 25 16 12 4 21 25 16 12
4 21 25 16 12 4 21 16 25 12
4 21 16 25 12
4 16 21 25 12
4 16 21 25 12
4 16 21 25 12 4 16 21 12 25
4 16 21 12 25
4 16 12 21 25
4 12 16 21 25

Shell sort

21 4 25 16 12 17
16 21
21 16
4 12 4 12
17 25
25 17
16 4 17 21 12 25 4 16 17 21 12 25
4 16 17 21 12 25
4 16 17 21 12 25
4 16 17 21 12 25 4 16 17 21 12 25
4 16 17 12 21 25
4 16 17 21 12 25
4 16 17 12 21 25 4 16 17 12 21 25
4 16 17 12 21 25
Merge sort

21 4 25 16 12 17 3 30

21 4 25 16 12 17 3 30

21 4 25 16 12 17 3 30

4 21 16 25 12 17 3 30

4 16 21 25 3 12 17 30

3 4 12 16 17 21 25 30

You might also like