Week 8 - Sorting Algorithms (Wednesday)
Learning Materials
You Try It #2
- This is a "try it and see what you can do" thing. Can you convert the pseudocode I gave you to actual working Python code?
- Being able to do this isn't an outcome of the course.
- But I think trying it is a good test of where you are at
- Start with the sort that made the most sense to you and see what you can accomplish.
- Add the code for that sort under its definition.
- Once you think you have it working remove the comment and the "return True" statement that is there just as a placeholder
- You can test your code by using the code already provided at the bottom of the file.
- The tester code that I have included prints the unsorted and then the (hopefully) sorted result as well as a comparison.
Explaining the YTIs
Now that you have done this, you can view my discussion about the two previous YTI activities.
Note, these videos are from a previous offering of the course. A few things may look different, but for the most part you should be able to follow along.
Bubble Sort
- Watch - "Paper Walkthrough" of the Pseudocode (Video, 18 minutes)
- I think it is important for me to SHOW you doing a "paper walkthrough" of the pseudocode so you can see the process.
- Watch - Converting from pseudocode to working code (Video, 10 minutes)
- Watch - Using PythonTutor.org (BETTER) (Video, 14 minutes)
- Watch - Using the built in tools in Thonny (Good) (Video, 8 minutes)
- Explore - The PythonTutor.org visualization tool I used in the last video so that you can play with it yourself
I'm not going to go into nearly the same level of detail with the other two sorts. Let's just convert them from pseudocode to python and then run them through PythonTutor. If you want to see paper walkthroughs for the pseudocode or talk to me about visualizing in Thonny, I will be happy to meet with you one-on-one and do this.
Insertion Sort
- Watch - Converting from pseudocode to working code (Video, 3 Minutes)
- Watch - Explaining what this sort does (Video, 18 Minutes)
- Explore - The visualization tool I used in the last video so that you can play with it yourself
Selection Sort
- Watch - Converting from pseudocode to working code (Video, 4 Minutes)
- Watch - Explaining what this sort does (Video ,12 Minutes)
- Explore - The visualization tool I used in the last video so that you can play with it yourself