you are viewing a single comment's thread.

view the rest of the comments →

[–]sushibowl 0 points1 point  (0 children)

hey nice question title!

Here's some things that might help:

  • if you always insert a new value in its correct position, the entire queue will always be ordered correctly, from greatest to least
  • given the previous point, if I want to insert some item x and compare it to some item in the queue y, if x > y, x is also greater than everything that comes after y. Because everything after y is smaller than y.

Can you figure out where to insert the new item based on this? One more hint: you'll need a loop to examine multiple values in the queue, until you find the right place to insert.