Académique Documents
Professionnel Documents
Culture Documents
Objectives
In this session, you will learn to:
Identify the algorithms that can be used to sort data
Sort data by using bubble sort
Sort data by using selection sort
Sort data by using insertion sort
Sort data by using shell sort
Ver. 1.0
Session 4
Ver. 1.0
Session 4
Ver. 1.0
Session 4
Ver. 1.0
Session 4
Session 4
Ver. 1.0
Session 4
0
arr
Ver. 1.0
1
2
Session 4
0
arr
Ver. 1.0
1
2
Session 4
0
arr
Ver. 1.0
1
2
Session 4
Swap
0
arr
Ver. 1.0
5
2
1
2
5
Session 4
Ver. 1.0
1
5
Session 4
Ver. 1.0
1
5
Session 4
Ver. 1.0
1
5
7
3
3
7
Session 4
1
5
Ver. 1.0
Session 4
Ver. 1.0
1
5
Session 4
Ver. 1.0
1
5
Session 4
Ver. 1.0
1
5
6
3
3
6
Session 4
1
5
Ver. 1.0
Session 4
Ver. 1.0
1
5
Session 4
Ver. 1.0
1
5
3
3
5
Session 4
1
3
Ver. 1.0
Session 4
Ver. 1.0
1
3
Session 4
3 5
Ver. 1.0
Session 4
0
arr
Ver. 1.0
3 5
Session 4
Ver. 1.0
Session 4
Ver. 1.0
Session 4
Answer:
The bubble sort algorithm has a quadratic order of growth.
Ver. 1.0
Session 4
Answer:
n 1 comparisons
Ver. 1.0
Session 4
Ver. 1.0
Session 4
Ver. 1.0
Session 4
0
arr
Ver. 1.0
105 120 10
200 20
Session 4
0
arr
Ver. 1.0
105 120 10
200 20
Session 4
0
arr
105 120 10
200 20
min
Ver. 1.0
Session 4
105
10 120 105
10 200 20
min
Ver. 1.0
Session 4
0
arr
Ver. 1.0
Session 4
10 120
20 105 200 120
20
min
Ver. 1.0
Session 4
0
arr
10 120
20 105 200 120
20
Ver. 1.0
Session 4
0
arr
10 120
20 105 200 120
20
min
Ver. 1.0
Session 4
0
arr
10 120
20 105 200 120
20
min
The third smallest
value is placed at its correct location after Pass 3
Ver. 1.0
Session 4
10 120
20 105 120
200 120
200
20
min
Ver. 1.0
Session 4
0
arr
10 120
20 105 120
200 200
20
The fourth smallest value is placed at its correct location after Pass 4
Ver. 1.0
Session 4
0
arr
Ver. 1.0
10 120
20 105 120
200 200
20
Session 4
Ver. 1.0
Session 4
Ver. 1.0
Session 4
Answer:
True
Ver. 1.0
Session 4
Answer:
n2
Ver. 1.0
Session 4
Ver. 1.0
Session 4
arr
Ver. 1.0
70
80 30
10
20
Session 4
arr
Ver. 1.0
70
80 30
10
20
Session 4
70
80 30
10
20
Sorted List
Ver. 1.0
Unsorted List
Session 4
70
80 30
10
20
Sorted List
Ver. 1.0
Unsorted List
Session 4
70
80
30
10 20
Sorted List
Ver. 1.0
Unsorted List
Session 4
70
80
30
10 20
Sorted List
Ver. 1.0
Unsorted List
Session 4
30
70 80
Sorted List
Ver. 1.0
10 20
Unsorted List
Session 4
30
70 80
Sorted List
Ver. 1.0
10 20
Unsorted List
Session 4
10
30
70 80
Sorted List
Ver. 1.0
4
20
Unsorted List
Session 4
10
30
70 80
Sorted List
Ver. 1.0
4
20
Unsorted List
Session 4
10
20 30
70
80
Sorted List
Ver. 1.0
Unsorted List
Session 4
arr
Ver. 1.0
70
80 30
10
20
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
Ver. 1.0
70
80 30
10
20
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
70
80 30
10
20
1.
2.
3.
Set j = i 1
4.
5.
Ver. 1.0
Session 4
arr
70
80 30
10
20
1.
2.
3.
Set j = i 1
4.
5.
Ver. 1.0
Session 4
arr
70
80 30
10
20
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
70
80 30
10
20
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
70
80 30
10
20
1.
2.
3.
Set j = i 1
4.
5.
Ver. 1.0
Session 4
arr
Ver. 1.0
70
80 30
10
20
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
Ver. 1.0
70
80 30
10
20
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
70
80 30
10
20
1.
2.
3.
Set j = i 1
4.
5.
Ver. 1.0
Session 4
arr
70
80 30
10
20
1.
2.
3.
Set j = i 1
4.
5.
Ver. 1.0
Session 4
arr
70
80 30
10
20
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
70
80 30
10
20
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
70
80 80
30
10
20
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
0
arr
70
Ver. 1.0
80
10
20
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
70
70 80
10
20
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
Ver. 1.0
70 80
10
20
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
30
70 80
10
20
1.
2.
3.
Set j = i 1
4.
5.
Ver. 1.0
Session 4
arr
Ver. 1.0
30
70 80
10
20
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
30
70 80
10
20
1.
2.
3.
Set j = i 1
4.
5.
Ver. 1.0
Session 4
arr
30
70 80
10
20
1.
2.
3.
Set j = i 1
4.
5.
Ver. 1.0
Session 4
arr
30
70 80
10
20
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
30
70 80
10
20
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
30
70 80
10
80
20
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
30
70
Ver. 1.0
80
20
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
30
70
70
80
20
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
0
arr
30
Ver. 1.0
70
80
20
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
30
30
70
80
20
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
0
arr
Ver. 1.0
30
70
80
20
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
10
30
70
80
20
1.
2.
3.
Set j = i 1
4.
5.
Ver. 1.0
Session 4
arr
10
30
70
80
20
1.
2.
3.
Set j = i 1
4.
5.
Ver. 1.0
Session 4
arr
10
30
70
80
20
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
10
30
70
80
20
1.
2.
3.
Set j = i 1
4.
5.
Ver. 1.0
Session 4
arr
10
30
70
80
20
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
10
30
70
80
20
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
10
30
70
80
20
80
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
10
30
70
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
4
80
Session 4
arr
10
30
70
70
80
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
10
30
Ver. 1.0
70
80
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
10
30
30
70
80
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
0
arr
10
Ver. 1.0
30
70
80
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
10
20
30
70
80
Ver. 1.0
1.
2.
3.
Set j = i 1
4.
5.
Session 4
arr
10
20
30
70
80
1.
2.
3.
Set j = i 1
4.
5.
Ver. 1.0
Session 4
Session 4
Ver. 1.0
Session 4
Ver. 1.0
Session 4
Ver. 1.0
Session 4
arr
Ver. 1.0
10
70
30 40
10
80
20
90
110
75
60
45
Session 4
arr
Ver. 1.0
10
70
30 40
10
80
20
90
110
75
60
45
Session 4
List 1 =
70 10 90
Pass = 1
60
List 3 =
arr
Ver. 1.0
40
20 75
List 2 =
10
30
80 110 45
10
70
30 40
10
80
20
90
110
75
60
45
Session 4
List 1 =
List 3 =
10
70
60
10 70
90
90
60
20
40
40
20 75
List 2 =
10
30
80
45 110
80 45
110
Apply
insertion
sort to sort the
The lists
are sorted
three lists
Ver. 1.0
Session 4
10
30
45
80
110
10
60 70
90
List 3 =
20
40 75
10
30 20
60
45
40
70
80
75
90 110
List 1 =
arr
Ver. 1.0
List 2 =
10
Session 4
70
List 2 =
30
60 40
80
90
10
30 20
60
45
40
70
80
75
90 110
arr
Ver. 1.0
10
75 110
10
Session 4
List 1 =
List 2 =
10
20 45
70
30
60 40
80
90
10
75 110
Ver. 1.0
Session 4
List 1 =
List 2 =
10
20 45
70
30
40 60
80
90
10
75 110
Ver. 1.0
Session 4
10
20 45
70
List 2 =
30
40 60
80
90
10
30 20
40
45
60
70
80
75
90 110
List 1 =
arr
Ver. 1.0
10
75 110
10
Session 4
arr
10
10
30 20
40
45
60
70
80
75
90 110
Ver. 1.0
Session 4
arr
10
10
20 30
40
45
60
70
75
80
90 110
Ver. 1.0
Session 4
Insertion sort
Selection sort
Bubble sort
Shell sort
Answer:
4. Shell sort
Ver. 1.0
Session 4
Ver. 1.0
Session 4
Ver. 1.0
Session 4
Ver. 1.0
Session 4