Warning This class is being recorded (and transcribed) (assuming Teams succeeds).
Approximate overview
Academic
Cultural
Peer
Wellness
We need more of these!
Misc
I forgot to fill in the pre-assessment for mini-project 9 even though I knew that I had to do so to make up for the prior missing pre-assessments and you reminded us to do so. Could I please turn it in today?
Sure.
Should we create a min-heap or a max-heap?
Please create a min-heap.
Does it matter if I write heapUp iteratively or recursively?
Nope. I think it’s easier to write recursively, but I ended up writing it iteratively when I did the lab.
Does it matter if I write heapDown iteratively or recursively?
Nope. I think it’s easier to write recursively, and I ended up writing it recursively when I did the lab.
Do you have hints on heapDown?
Strategy one: Write a helper procedure that returns the index of the smaller child. You can then compare
ito that index. (Make sure that you check whether there is a right child.)
Strategy two: Keep track of the index of the smallest element seen so far. Initially, that’s
i. If you have a left child and the left child is smaller, you can update that index. If you have a right child and the right child is smaller, you can update that index. Once you’re done, you can compare that index toi. If they are different, swap and recurse (recur). (I think CLRS use this strtegy.)