It contains "Selection Sort", "Merge Sort" and "Binary Search Tree" projects
[22,27,16,2,18,6] -> Insertion Sort
Write the stages of the above sequence according to the sort type.
[22,27,16,2,18,6]
[16,22,27,2,18,6]
[2,16,22,27,18,6]
[2,6,16,22,27,18]
[2,6,16,18,22,27]
Worst Case: O(n^2) Avarage Case: O(n^2) Best Case: O(n)
Time Complexity:
For which case does the number 18 apply after the array is sorted? Write. After sorting the array, the number 18 is in the middle of the array, so the number 18 is covered by the Avarage Case.
Avarage Case: [2,6,16,18,22,27]
[2,3,5,8,7,9,4,15,6]
[2,3,4,8,7,9,5,15,6]
[2,3,4,5,7,8,9,15,6]
[2,3,4,5,6,8,9,15,7]
[16,21,11,8,12,22] -> Merge Sort
[16,21,11] - [8,12,22] STEP 1
[16,21] - [11] - [8,12] - [22] STEP 2
[16] - [21] - [11] - [8] - [12] - [22] STEP 3
[16,21] - [11] - [8,12] - [22] STEP 4
[11,16,21] - [8,12,22] STEP 5
[8,11,12,16,21,22] STEP 6
O(nlogn)
7
7
/
5
7
/
5
/
1
7
/ \
5 8
/
1
7
/ \
5 8
/
1
\
3
7
/ \
5 8
/ \
1 6
/ \
0 3
7
/ \
5 8
/ \ \
1 6 9
/ \
0 3
7
/ \
5 8
/ \ \
1 6 9
/ \
0 3
\
4
7
/ \
5 8
/ \ \
1 6 9
/ \
0 3
/ \
2 4