Re: [CODE] Priority Queues :: HowTo?

From: Justin Adler (spam@WORLD-DOMINATION.COM.AU)
Date: 02/13/02

Hello All. :)

>> With an AVL tree, this would be reduced to a little under 11.

AVL trees .. hmm .. lets have a look

*does some google searches ... checks the AVL readme in the ftp site*

hmm. ok intersting.

Now there is something i don't understand with these AVL trees. To insert a
NODE into the tree, it has to have a KEY. I'm not sure what my KEY IS, in
this case though.

For example. If I was at a node that was the #40. and the Right->#55 and
Left->#43. I'm trying to insert a new node, #47. I assume with an AVL tree
(lets keep it simple, it's not a balanced one), i would decend down one
level to the LEFT #43, and add it there (to the left or right, i don't

   But i don't know the KEY....

   Unless you are saying that i need to re-think what my KEY IS.

   I'm assuming my key is the PRIORITY. Ie. Key#1 == most common / accessed
room == top of tree.  But you are saying -> forget that! the KEY is the
RNUM / VNUM / Room Num (however you impliment your room system), and that u
just place it into the tree normally, and that on average you most common
rooms will only be a few levels down. The most common room might not be at
the top / head of the tree ... but it will be just a few jumps to it.  As
opposed to a priority queue which i was thinking of originally, the most
common room would be at the very top BUT the rest are already a few jumps
to get to ... so on AVERAGE, the AVL kicks arse all over the priorty list.


>> unless you are making this list solely for the purpose
>> of seeing what the most popular room is, you should use
>> a tree or hash of some sort ...

   So this AVL thingo isn't the best solution after all? There are more
effecient solutions?

   Please forgive my ignorance folks with this Data Structure Algorithm

   Thank you in advance to any more answers :)

-Pure Krome-

   | FAQ: |
   | Archives: |
   | Newbie List:   |

This archive was generated by hypermail 2b30 : 06/25/03 PDT