0% found this document useful (0 votes)
18 views7 pages

Run An Insertion Sort, Selection Sort & Bubble Sort Algorithm For The Following List (Do It in Powerpoint) : 4,3,10,1,5,9

The document demonstrates three sorting algorithms: insertion sort, selection sort, and bubble sort. It provides the steps to implement each algorithm on a sample list of numbers.

Uploaded by

saskia katutu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views7 pages

Run An Insertion Sort, Selection Sort & Bubble Sort Algorithm For The Following List (Do It in Powerpoint) : 4,3,10,1,5,9

The document demonstrates three sorting algorithms: insertion sort, selection sort, and bubble sort. It provides the steps to implement each algorithm on a sample list of numbers.

Uploaded by

saskia katutu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Run an Insertion Sort, Selection Sort & Bubble

Sort
Algorithm for the
following list (Do it in powerpoint):

4,3,10,1,5,9
INSERTION SORT

4 3 10 1 5 9

3 4 10 1 5 9

1 3 4 10 5 9

1 3 4 5 9 10
for j ← 3 to n
do key ← A[ j ]
Insert A[ j ] into the sorted sequence A[1 . . j -1]
i←j-1
while i > 0 and A[i] > key
do A[i + 1] ← A[i]
i←i–1
A[i + 1] ← key
SELECTION SORT

4 3 10 1 5 9
1 3 4 5 10 9
1 3 10 4 5 9

1 3 4 5 9 10

1 3 4 10 5 9
n ← length[A]

for j ← 1 to n – 1

do smallest ← j

for i ← j + 1 to n

do if A[i] < A[smallest]

then smallest ← i
BUBBLE SORT
4 3 10 1 5 9
1 3 4 10 5 9
4 3 1 10 5 9
1 3 4 5 10 9
4 1 3 10 5 9
1 3 4 5 9 10
1 4 3 10 5 9
for i  1 to length[A]

do for j  length[A] downto i + 1

do if A[j] < A[j -1]

then exchange A[j]  A[j-1]

You might also like