0% found this document useful (0 votes)
29 views3 pages

Sorting - Worksheet

The document provides examples of applying selection sort and insertion sort algorithms to various data sets. For each example, it records the data after each pass of the sorting algorithm. It also tracks the number of comparisons and exchanges during one example of selection sort.

Uploaded by

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

Sorting - Worksheet

The document provides examples of applying selection sort and insertion sort algorithms to various data sets. For each example, it records the data after each pass of the sorting algorithm. It also tracks the number of comparisons and exchanges during one example of selection sort.

Uploaded by

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

Question 1: Apply the Selection sort algorithm to the data listed.

Record the data after


EACH pass.

51 64 29 36 43 97 80 19 Original
19 64 29 36 43 97 80 51 Pass 1
19 29 64 36 43 97 80 51 Pass 2
19 29 36 64 43 97 80 51 Pass 3
19 29 36 43 64 97 80 51 Pass 4
19 29 36 43 51 97 80 64 Pass 5
19 29 36 43 51 64 80 97 Pass 6
19 29 36 43 51 64 80 97 Pass 7

Question 2: Apply the Selection sort algorithm to the data listed. Record the data after Pass 4.
A pass is completed each time the algorithm returns to Step 3.

75 41 59 34 87 63 98 22 Original
22 34 41 59 87 63 98 75 Pass 4

Question 2: As you perform the Selection sort on the data set provided, keep track of how
many comparisons and exchanges are performed. Remember to record on the
next line once each pass is complete (Step 3).

Original data set: 48 23 36 95 14 50 61 72

Passes Comparisons Exchanges


Pass 1 7 1
Pass 2 6 0
Pass 3 5 0
Pass 4 4 1
Pass 5 3 1
Pass 6 2 1
Pass 7 1 1
Totals 28 5
Question 3: Apply the Insertion sort algorithm to the data listed and record the data after
EACH pass. A pass is completed each time the algorithm returns to Step 3.

51 64 29 36 43 97 80 19 Original
51 64 29 36 43 97 80 19 Pass 1
29 51 62 36 43 97 80 19 Pass 2
29 36 51 62 43 97 80 19 Pass 3
29 36 43 51 62 97 80 19 Pass 4
29 36 43 51 62 97 80 19 Pass 5
29 36 43 51 62 80 97 19 Pass 6
19 29 36 43 51 62 80 97 Pass 7

Question 4: Apply the Insertion sort algorithm to the data listed. Record the data after Pass 4.

75 41 59 34 87 63 98 22 Original
34 41 59 75 87 63 98 22 Pass 4

Question 5: Apply the Insertion sort algorithm to the data listed. Record the data after Pass 6.

48 23 36 95 14 50 61 72 Original
14 23 36 48 50 61 72 95 Pass 6

You might also like