Thank you for reading! In my implementation of a MaxPriority Queue, when a value is inserted, the function accepts the value and the priority value, and stores this data in an object representing each node of the tree.
When the bubble and trickle methods execute, all comparisons are made using the priority property of those nodes, not the values themselves. This ensures that nodes bubble up or trickle down based on their assigned priority levels.
Thank you for reply!
But I still don't see any comparisons using priority. Yeah, you pass priority, but you compare objects, not priority values. I talk about Full code section -> class MaxHeapPriorityQueue. So MaxHeapPriorityQueue class looks the same as MaxHeap (except formatting)
Oh! I see what you mean now. It looks like I forgot to update the gist from my local file (which is what I looked at after your previous comment). I updated the gist from my local file, namely lines 28 of _bubble_up() and 73 & 88 of _trickle_down()
Thank you for bringing it to my attention, and persisting!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Artem,
Thank you for reading! In my implementation of a MaxPriority Queue, when a value is inserted, the function accepts the value and the priority value, and stores this data in an object representing each node of the tree.
When the
bubble
andtrickle
methods execute, all comparisons are made using the priority property of those nodes, not the values themselves. This ensures that nodes bubble up or trickle down based on their assigned priority levels.Thank you for reply!
But I still don't see any comparisons using priority. Yeah, you pass priority, but you compare objects, not priority values. I talk about Full code section -> class MaxHeapPriorityQueue. So MaxHeapPriorityQueue class looks the same as MaxHeap (except formatting)
Oh! I see what you mean now. It looks like I forgot to update the gist from my local file (which is what I looked at after your previous comment). I updated the gist from my local file, namely lines 28 of _bubble_up() and 73 & 88 of _trickle_down()
Thank you for bringing it to my attention, and persisting!