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

Activity 8

The document compares bubble sort and insertion sort algorithms for sorting an unsorted array of numbers. It shows the step-by-step process of applying each algorithm to sort the sample array containing the numbers 4, 5, 8, 9, 10, 1, 2, 6, 7, 3. Bubble sort requires 23 swaps to fully sort the array, while insertion sort requires fewer swaps.

Uploaded by

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

Activity 8

The document compares bubble sort and insertion sort algorithms for sorting an unsorted array of numbers. It shows the step-by-step process of applying each algorithm to sort the sample array containing the numbers 4, 5, 8, 9, 10, 1, 2, 6, 7, 3. Bubble sort requires 23 swaps to fully sort the array, while insertion sort requires fewer swaps.

Uploaded by

Jaysa Ramos
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

WORKSHEET ACTIVITY 8

Bubble Sort vs Insertion Sort

Unsorted Array:
4 5 8 9 10 1 2 6 7 3

a. Bubble Sort
4 5 8 9 10 1 2 6 7 3

4 5 8 9 1 10 2 6 7 3

4 5 8 9 1 2 10 6 7 3

4 5 8 9 1 2 6 10 7 3

4 5 8 9 1 2 6 7 10 3

4 5 8 9 1 2 6 7 3 10

4 5 8 1 9 2 6 7 3 10

4 5 8 1 2 9 6 7 3 10

4 5 8 1 2 6 9 7 3 10

4 5 8 1 2 6 7 9 3 10

4 5 8 1 2 6 7 3 9 10

4 5 1 8 2 6 7 3 9 10
4 5 1 2 8 6 7 3 9 10

4 5 1 2 6 8 7 3 9 10

4 5 1 2 6 7 8 3 9 10

4 5 1 2 6 7 3 8 9 10

4 5 1 2 6 3 7 8 9 10

4 5 1 2 3 6 7 8 9 10

4 1 5 2 3 6 7 8 9 10

4 1 2 5 3 6 7 8 9 10

4 1 2 3 5 6 7 8 9 10

1 4 2 3 5 6 7 8 9 10

1 2 4 3 5 6 7 8 9 10

1 2 3 4 5 6 7 8 9 10

b. Insertion Sort
4 5 8 9 10 1 2 6 7 3

4 5 8 9 1 10 2 6 7 3

4 5 8 1 9 10 2 6 7 3

4 5 1 8 9 10 2 6 7 3

4 1 5 8 9 10 2 6 7 3

1 4 5 8 9 10 2 6 7 3

1 4 5 8 9 2 10 6 7 3

1 4 5 8 2 9 10 6 7 3

1 4 5 2 8 9 10 6 7 3

1 4 2 5 8 9 10 6 7 3

1 2 4 5 8 9 10 6 7 3

1 2 4 5 8 9 6 10 7 3

1 2 4 5 8 6 9 10 7 3

1 2 4 5 6 8 9 10 7 3
1 2 4 5 6 8 9 7 10 3

1 2 4 5 6 8 7 9 10 3

1 2 4 5 6 7 8 9 10 3

1 2 4 5 6 7 8 9 3 10

1 2 4 5 6 7 8 3 9 10

1 2 4 5 6 7 3 8 9 10

1 2 4 5 6 3 7 8 9 10

1 2 4 5 3 6 7 8 9 10

1 2 4 3 5 6 7 8 9 10

1 2 3 4 5 6 7 8 9 10

At the end of the sorting process, write the number of occurrences of exchange or swap.

= 23 swaps

You might also like