File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between [--nItems] and [nItems-1]??

 
Nadine Ernest
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the priority queue,
i dont understand these two methods....

they are the opposite of what should be done,, i think they give the maximum but in the data structures book it says the following

to remove the minimum:


and the other method is to peek on the minimum in the PRIORITY QUEUE:


this way, its gonna peek on the maximum --------> this is what i think

but the right thing is that it peeks on the minimum without changing anything this is from the book and my lectures so its correct but i just dont get it soo please help???

 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The difference between the two methods you posted is this:

In the first version, you are decrementing the variable nItems. So the value of the variable nItems is changed.
In the second version, you are not changing the value of the variable nItems.
 
Nadine Ernest
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aha...thank youuuu soo much!!

i totally misunderstood the whole thing,,,i read it upside down! (silly me!)

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic