Sinisterly
Introduction to Sorting and Sorting Algorithms - Part 2 - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Coding (https://sinister.li/Forum-Coding--71)
+--- Thread: Introduction to Sorting and Sorting Algorithms - Part 2 (/Thread-Introduction-to-Sorting-and-Sorting-Algorithms-Part-2)

Pages: 1 2


RE: Introduction to Sorting and Sorting Algorithms - Part 2 - Coder-san - 11-29-2013

For the merge function I could understand the steps, but what does "divide" even do?

How is this
Code:
-> [5,9,1,4,10,12,8]

different from this?
Code:
-> [5] [9] [1] [4] [10] [12] [8]



RE: Introduction to Sorting and Sorting Algorithms - Part 2 - Psycho_Coder - 11-29-2013

(11-29-2013, 09:10 PM)Coder-san Wrote: For the merge function I could understand the steps, but what does "divide" even do?

How is this
Code:
-> [5,9,1,4,10,12,8]

different from this?
Code:
-> [5] [9] [1] [4] [10] [12] [8]

In this case

Code:
-> [5,9,1,4,10,12,8]

It is one single array.

But in this case :-

Code:
-> [5] [9] [1] [4] [10] [12] [8]

They are all individual arrays of size one. In the merge function we check and then merge the arrays to form another array. Then subsequently they are check and merged together.

The basic this is that it occurs in different levels in the stack frame or at a different node in the recursion tree, then we move up in the tree level.