There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in Language Help.
Agree with a comment or answer? Like () to up-vote the contribution!
Why in description of general shape of method in pseudocode we get the smallest child and compare it with parent?
Blockquote
starting with our first element…
while there’s at least one child present: get the smallest child’s index compare the smallest child with our element
if our element is larger, swap with child
set our element index to be the child
In “Instructions” we get larger child and compare it with child and this is has more logic, as for me
I was confused about this myself, so I had a conversation with ChatGPT, which is where I learned that CC likely does it like this to reinforce the concept, because other languages don’t have an elegant tuple unpacking solution like parallel assignment. You have to hard code it like they had you do here. The idea is that you will be able to heapify in any language
My understanding is that the pseudo-code needs to be amended as in bold below.
starting with our first element…
while there’s at least one child present:
get the largest child’s index
compare the largest child with our element
if our element is smaller swap with child
set our element index to be the child