0
How does MergeSort algorithm works?
It is said that merge function doesn't occure until array isn't divided on sigle elements. But how can all elements in array be sorted when then size is 1? You ony compare the first two elemnts of array. But doesn't Merge function occurs every time recursion is called. I analysed it in comment in code, but my analysis isn't correct. https://code.sololearn.com/cG9XyMeitDMR/?ref=app
1 ответ
+ 2
I think the best way for you to analyse this is to add exactly the output the you wrote in the comments below your code 🙂 Just add some cout's before you call functions and/or when you step in, print values of local variables and parameters, and trace back how that thing works 🍀🙂