Merge sort, the recursion part

后端 未结 3 1758
猫巷女王i
猫巷女王i 2021-01-22 21:00

After studying the merge sort for a couple of days, I understand it conceptually, but there is one thing that I don\'t get.

What I get:

1.) It takes a list, for

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-22 21:37

    Once the list only contains one element, each pair of leaves are sorted and joined. Then you can traverse through the list and find out where the next pair should be inserted. The recursion "knows" nothing about going back up the recursion tree, rather it is the act of sorting and joining that has this effect.

提交回复
热议问题