On 2017-03-30, Elo Okonkwo wrote:
> Thanks so much everyone.
>
> I've figured it out. It was the recursive bit that got me
> confused, its a bit difficult debugging recursive functions.
It doesn't have to be!
I recommend debugging recursive functions with small,
Thanks so much everyone.
I've figured it out. It was the recursive bit that got me confused, its a
bit difficult debugging recursive functions.
On Wed, Mar 29, 2017 at 1:36 AM, Steven D'Aprano
wrote:
> On Tue, Mar 28, 2017 at 03:56:16PM +0100, Elo Okonkwo wrote:
> > Can
On Tue, Mar 28, 2017 at 03:56:16PM +0100, Elo Okonkwo wrote:
> Can someone pls explain this Merge Sort Algorithm, especially the Recursive
> bit of it.
Take a pack of cards and shuffle them. Now you want to sort the cards.
Put the cards down in a pile in front of you and think about sorting it.
On 28/03/17 15:56, Elo Okonkwo wrote:
> Can someone pls explain this Merge Sort Algorithm,
You can try reading this generic explanation.
It's not Python but the explanation seems fairly clear.
http://www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/Sorting/mergeSort.htm
HTH
--
Alan G
This is the Result of that of the Merge Sort Function:
I have never been more confused!!, practically spent the whole day on
this piece of code:
Splitting [54, 26, 93, 17, 77, 31, 44, 55, 20]
Splitting [54, 26, 93, 17]
Splitting [54, 26]
Splitting [54]
Merging [54]
Splitting [26]
Merging
This is the Result form that piece of code:
Splitting [54, 26, 93, 17, 77, 31, 44, 55, 20]
Splitting [54, 26, 93, 17]
Splitting [54, 26]
Splitting [54]
Merging [54]
Splitting [26]
Merging [26]
Merging [26, 54]
Splitting [93, 17]
Splitting [93]
Merging [93]
Splitting [17]
Merging [17]
Can someone pls explain this Merge Sort Algorithm, especially the Recursive
bit of it.
def mergeSort(alist):
print("Splitting ",alist)
if len(alist)>1:
mid = len(alist)//2
lefthalf = alist[:mid]
righthalf = alist[mid:]
mergeSort(lefthalf)