ScratchData LogoScratchData
Back to jgatcomb's profile

Sort A List (How To: Inplace Heapsort)

JGjgatcomb•Created March 15, 2014
Sort A List (How To: Inplace Heapsort)
18
7
537 views
View on Scratch

Instructions

This is a "How To" program explaining how to sort a list using a heapsort I recommend using Turbo Mode. Click on the green flag to see it in action Adjust the List Size variable if you want to try different sized lists A couple of reasons a heapsort may be more desirable than a quicksort are: A. Worst case complexity is only O(N log N) vs O(N^2) for quicksort B. Iterative version is straight forward (recursion in Scratch requires you to manage your own stack) It should be noted that a heapsort is not a stable sort. The other downside to implementing any algorithm in Scratch is that lists are 1-based and almost all examples are 0 based. Please let me know if you have questions or comments. Cheers, Joshua

Description

Added 2013-08-17 See http://en.wikipedia.org/wiki/Heapsort

Project Details

Project ID19307380
CreatedMarch 15, 2014
Last ModifiedMarch 15, 2014
SharedMarch 15, 2014
Visibilityvisible
CommentsAllowed