Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Queue priority and circular queue

Which one is much better? queue, priority queue or circular queue? why ? and does it apply any condition

The all have their uses. Queue is used in situations where priority doesn't matter. EX: A printer taking orders simultaneously.

Priority Queue is more useful in situations where some people do have precedence. EX: you create a database of patients at a hospital. Some are going to be of a higher priority than others. Unstable patient > stable patient. There are probably better examples but you get the gist.

Circular Queue's only advantage is having ease of access to the first object in the queue and last object in the queue. If you are concerned about that then you use it. I don't have a useful example. Maybe others will comment with better examples.

Always Unstable patient > stable patient !!!

Great examle :)))))

1 Answer

Reposting as answer for iftekhar:

The all have their uses. Queue is used in situations where priority doesn't matter. EX: A printer taking orders simultaneously.

Priority Queue is more useful in situations where some people do have precedence. EX: you create a database of patients at a hospital. Some are going to be of a higher priority than others. Unstable patient > stable patient. There are probably better examples but you get the gist.

Circular Queue's only advantage is having ease of access to the first object in the queue and last object in the queue. If you are concerned about that then you use it. I don't have a useful example. Maybe others will comment with better examples.