Java Show Contents Initially Empty Priority Queue Following Statements Execute Assume B C Q37246783

java

Show the contents of an initially empty priorityqueue after each of the followingstatements execute.

Assume that a, b, c, d, and e are objects and that the numbernext to the object specifies its priority.

For example, object 1a has priority 1 and object 2b has priority2.

Lower numbers have higher priorities.

Example: 2b has a higher priority than 3d

Example: 2b has the same priority as 2e.

Your answer should have 13 lines that show thecontents of pq1.

Put the front of the priority queue on theleft and the back on the right.

pq1.add(1d) pq1.add(2e) pq1.add(1a) pq1.add(2a) pq1.add(1c)pq1.add(1e);pq1.remove() pq1.add(pq1.remove()) pq1.add(pq1.getFront()) pq1.remove() pq1.remove()pq1.remove();pq1.remove();


Answer


pq1.add(1d)

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.