Back to course home
0% completed
Vote For New Content
Why do we not need to push the element back onto the heap during the pop() metho...
Ben
Jul 22, 2022
Why do we not need to push the element back onto the heap during the pop() method??
0
0
Comments
Comments
P
Pete Stenger3 years ago
When we push, we are pushing the character, order added, and frequency at that moment in time.
So push(2), push(2), push(2)
Adds 3 items to the stack 2 freq=1 2 freq=2 2 freq=3
When we pop, The frequency goes down by 1, which is handled naturally as "2 freq=2" is alr...
On this page