ScratchData LogoScratchData
Back to gtoal's profile

mergesort

GTgtoal•Created January 31, 2015
mergesort
6
0
341 views
View on Scratch

Instructions

This isn't super fast (I haven't done any tricks to optimise it) but it's easy to follow, and it's the obvious way to implement a merge sort in Scratch. Note this is *not* a linked-list merge, it's an array merge. It updates the input array in place *and* requires a second array of the same size to sort into. With either hacked blocks or two copies of the sorting code, we could avoid a large amount of data copying (i.e. copy 'from' to 'to' without copying back on each recursive call - just flip 'from' & 'to' over and do an optional final copy back.)

Description

Written from first principles. I was quite pleased to see how similar it was to the reference implementation in Wikipedia when I checked it after completion.

Project Details

Project ID45782998
CreatedJanuary 31, 2015
Last ModifiedJanuary 31, 2015
SharedJanuary 31, 2015
Visibilityvisible
CommentsAllowed