Discuss the queue data structure What is it How can it be us
Discuss the queue data structure.
What is it?
How can it be used?
What support exists for queues in the Java Class Library Collections Framework? Do you think this support is easy to understand and use? Why or why not?
Discuss the pros and cons of creating your own queue classes vs. using those provided by the Java Class Library Collections Framework. Make sure you take into consideration the ability to handle any kind of objects (generics).
What is a priority queue? How does it differ from a regular queue? Give an example of a use for a priority queue.
Solution
Queue is also one of the data structure that means FIFO that means the if the element is inserted from one side and after that if it wants to take it out the deletion takes from last onwards.
Queue can be used to implement 1. Radix sort 2. Quick sort 3. Recursion 4. Depth first search.
Java collection framework are the fundamental aspects of the programming language. java.util.queue is an implementation that is present in java and with this we can execute programs very easily. when you use a queue in the programming you dont need to know that which implementation is used because collection has been costructed and it will look after the rest of the work.
It\'s definitely possible to write your own queue of queues - in fact, it\'s possible to write any of the STL container classes - but starting off by using queue is not the right way to do this. If you want to make a queue of queues, start off by thinking about how to make a simple queue.
A priority queue is different from a \"normal\" queue, because instead of being a \"first-in-first-out\" data structure, values come out in order by priority. A priority queue might be used, for example, to handle the jobs sent to the Computer Science Department\'s printer: Jobs sent by the department chair should be printed first, then jobs sent by professors, then those sent by graduate students, and finally those sent by undergraduates. The values put into the priority queue would be the priority of the sender (e.g., using 4 for the chair, 3 for professors, 2 for grad students, and 1 for undergrads), and the associated information would be the document to print. Each time the printer is free, the job with the highest priority would be removed from the print queue, and printed.
