Question: In Java language --- so far what I wrote ---- public void removeDuplicates (HeapIntPriorityQueue pq) { Stack aux = new Stack (); while (!pq.isEmpty()) {

 In Java language --- so far what I wrote ---- public

In Java language

--- so far what I wrote ----

public void removeDuplicates (HeapIntPriorityQueue pq) {

Stack aux = new Stack();

while (!pq.isEmpty()) {

int n = pq.remove();

aux.push(n);

Write a method called removeDuplicates that accepts a PriorityQueue of integers as a parameter and modifies the queue's state so that any element that is equal to another element in the queue is removed. For example, if the queue stores 17, 7,8,8, 8, 10, 45, 45], your method should modity the queue to store 17, 8, 10, 45]. You may use one stack or queue as auxiliary storage

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!