西瓜科学家的笔记本
Tuesday, January 26, 2016
Merge sort - Java
Basic algorithm:
1. If list has one element, return;
2. Divide list in half
3. Sort first half
Sort second half (use recursion)
4. Merge sorted lists.
Best = Worst = O(nlogn)
Quick sort best = average = O(nlogn), worst = O(n^2)
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment