Skip to content

Commit 9f07a44

Browse files
committed
add time and space comlexity
1 parent f0aeaed commit 9f07a44

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sorting/merge_sort.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
arrays and compare their elements. We add the smaller element to the result array and move the corresponding index variable.
1111
Finally, we append the remaining elements of the left or right array to the result array and return it.
1212
13+
The time complexity of Merge Sort is O(n*log n), where n is the number of elements in the array,
14+
and the space complexity is O(n) due to the use of the temporary arrays during the merging phase.
15+
1316
*/
1417
package main
1518

0 commit comments

Comments
 (0)