sorting a doubly linked list with merge sort

前端 未结 5 1525
悲&欢浪女
悲&欢浪女 2020-12-02 01:33

I have found this code in the internet and it was for arrays ,I want to change it for doubly linked list(instead of index we should use pointer) would you please help me tha

5条回答
  •  情话喂你
    2020-12-02 02:27

    Another idea is to create an array with all the elements of the list, sort the array and then insert the elements to the list again.

    Pro: very simple to implement, faster if poor implementation of list mergesort (maybe also faster than good implementations)

    Contra: uses some extra space (O(n))

提交回复
热议问题