# Merge Sort Versus Heap Sort #### Time Complexity | Data Structure | Time Complexity[Best] | Time Complexity[Average] | Time Complexity[Worst] | | ------------- | ------------- | ------------- | ------------- | | Heap Sort | O(n log(n)) | O(n log(n)) | O(n log(n)) | | Merge Sort | O(n log(n)) | O(n log(n)) | O(n log(n)) | #### Chart ![](https://i.imgur.com/FArPPAx.png) #### Descriptions: * Heap sort uses close to the right number comparisons but need to move data around quite a bit. It can be done in a way that uses very little extra memory. It's probably googd when memory is tight, and you are sorting many small items that come stored in an array. * Merge sort is good for data that's too big to have in memory at once, because its pattern of storage access is very regular. It also uses even fewer comparisons then heap sort, and is expecially suited for data stored as linked lists.