Implement the merge sort algorithm.
Merge sort is often used in database scenarios, because often we store data in different files and need to merge them. It’s also useful in distributed systems where data needs to be merged from multiple source. A great use case could be mapReduce
!
Also, you probably merge every morning at work when you pull the latest code!
Another nice recurisve sorting algorithm!
Time Complexity
O(n*log(n))
Space Complexity
O(n)
Recurisve depth of stack is O(log(n))
. We use helper lists (L
+ R
) that store all elements in our list for O(n)
.
while
loops!Quick Links
Legal Stuff