Question: Problem 3 (40 points) Implement the selection sort algorithm on a Queue of long-type items. Specifically, you are given the Queue class implementation and you
Problem 3 (40 points) Implement the selection sort algorithm on a Queue of long-type items. Specifically, you are given the Queue class implementation and you need to write a method that takes a Queue and sorts it using the selection sort idea. The implementation of the Queue class for long data type is given in the lecture slides (the code skeleton including the implementation of the Queue class is provided below for your convenience). You should go over the Queue and use enqueue0. dequeue. peek0.. methods to sort the items in the Queue. You must work with the queue, that means you are not allowed to convert the Queue into an array (or some other data structure and then sort the array. Also, you should write the sorting part that means you cannot call a library sort method on the Queue. import java.util.NoSuchElementException; class Queue private int maxSize: private long [ queArray; private int front; private int reari private int nItems; public Queue (int s) /7 constructor maxSizes; queArray new long [maxSize]; front-0; rear-1; nItems0; public long dequeue// take item from front of queue if (isEmpty)) throw new
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
