DataStructure icon indicating copy to clipboard operation
DataStructure copied to clipboard

Time complexity of merge sort

Open littleNewCat opened this issue 8 years ago • 3 comments

hello, the Time complexity of merge sort maybe O(nlogn), right?

littleNewCat avatar Jul 02 '17 14:07 littleNewCat

Yeah, the complexity of Merge Sort is always O(nlogn). And, it is independent of initial sequence.

githubofrico avatar Jul 05 '17 00:07 githubofrico

链表类里的删除重复元素对于连续的重复元素不能删除,例如3,2,2,2,4,4,这样修改就对了 Node<E> cur = head.next; while (cur != null) { Node<E> temp = cur; while ( temp.next != null) { if (cur.data.equals(temp.next.data)) { Node<E> DupNode = temp.next; temp.next = DupNode.next; DupNode.next = null; size--; } else { temp = temp.next; } } cur = cur.next; }

wccou avatar Dec 05 '17 08:12 wccou

o(n^2) right?

JXWJS avatar Jun 19 '18 09:06 JXWJS