#PriorityQueues store data like BST trees ?

1 messages · Page 1 of 1 (latest)

viral gladeBOT
#

<@&987246399047479336> please have a look, thanks.

viral gladeBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

keen laurel
#

@void drum there is no array there

#

if you want to figure out how the priority queue is storing elements you can read the code or make a heap dump

void drum
#

I printed out the elements but how is it being stored in the debugger

keen laurel
#

🤷‍♂️

#

thats a jetbrains question

void drum
#

im meaning like the code. is it random

keen laurel
#

but this is how PriorityQueue stores things

#

read the first comment

void drum
# keen laurel

strange.. my documentation says something about natural ordering but looking at the debugger its not stored in its natural ordering

keen laurel
#

....

#

its a heap

void drum
#

yes but wouldn't this 12 be out of place

void drum
#

its a complete binary tree so the 12 is the left node of 19

errant snow
loud rampart
#

essentially, pull() and similar is in-order

#

but iteration (what ur debugger shows here) is in any-order

#

the PQ internally doesnt store them ordered

#

its half-ordered internally

#

it does the rest during the pull() call

#

so it cant give u the correct order during iteration

gritty holly
#

They store data in a heap

#

Which is similar to a tree

#

But it allows duplicates and the iteration order is not specified

#

It's stored in an array where node children appear at doubled index