You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -11,10 +12,13 @@ export function mergeSort(array: number[]): number[] {
11
12
constmiddle=Math.floor(length/2);
12
13
constleft=array.slice(0,middle)
13
14
constright=array.slice(middle)
15
+
console.log("left",left);
16
+
console.log("right",right)
14
17
15
-
// Recursive point
18
+
// Recursive point (recursive case)
19
+
// Mỗi lần merge thì mất n
16
20
returnmerge(
17
-
mergeSort(left),
21
+
mergeSort(left),// Chia đôi chiều dài của mảng để mảng đạt 1 phần tử tốn logN thời gian (logN lần lặp => Ví dụ mảng có 256 phần tử => Tốn log256 => tốn 8 lần chạy của hàm )
0 commit comments