Let’s write more code! Implement HeapSort per the algorithm* to sort an array A in ascending order.
Which algorithm? You pick. A big part of “algorithms” is knowing how
to convert mathy pseudo-code into your language of choice. So use the
textbook, use the slides, use the Internet... just pick one and run with it.
Here’s what you need to turn in:
- Where you got the algorithm from
- Your code
- The output of your code
- An explanation of why you chose the test cases you did
- How many test cases do I need? You decide. It’s your code, so you should best know where things might go wrong. Add test cases that explore each of these places where something could break.
- Can I get the algorithm off Wikipedia? Yes. It just has to implement HeapSort.
- Are HeapSort and insertion into a Heap the same thing? NO. They are most definitely not the same thing! Make sure you’re doing HeapSort!
- Why are you making us write so much code that you said will just be in a library anyway? Because the best way to get better at coding is to write more code. That’s why I say “Let’s write more code!” in every homework and on the tests. Keep doing it and you’ll get just a little bit better every time. 👍