[Java] Efficiency Comparison of two Implemented Queues : Circular Array Queue and SSQueue and its enqueue and dequeue operations
Need to write a program that compares the efficiency of the queue implementations. To do so, you need to find and compare the running times of 1 the following two scenarios for both queue implementations: 3.1 Scenario 1: Alternating Sequence of Enqueues and Dequeues For every n ∈ {20, 50, 100, 1000, 10000, 100000, 1000000}, do the following: 1. long startTime = System.nanoTime(); 2. add the first n non-negative integers to the queue. 3. foreveryi∈{0,1,...,n−1},dothefollowing: (a) enqueue(i+n) (b) dequeue() 4. long endTime = System.nanoTime(); 5. long totalTime = endTime - startTime; 6. System.out.println(n + “, ” + totalTime); 3.2 Scenario 2: Random Sequence of Enqeueus and Dequeues For every n ∈ {20, 50, 100, 1000, 10000, 100000, 1000000}, do the following: 1. long startTime = System.nanoTime(); 2. add the first n non-negative integers to the queue. 3. foreveryi∈{0,1,...,n−1},dothefollowing: (a) if (Math.random() < 0.5) enqueue(i + n); (b) else dequeue(); 4. long endTime = System.nanoTime(); 5. long totalTime = endTime - startTime; 6. System.out.println(n + “, ” + totalTime);
################## QueueEfficencyTester.java #################
/**
* Comparing efficency for two queue i.e. Circular Array queue and
SSQueue
*/
public class QueueEfficencyTester {
public static void main(String[] args) {
checkEfficencyOfCircularQueue();
checkEfficencyOfPriorityQueue();
}
/**
* Check efficency of priority queue.
*/
private static void checkEfficencyOfPriorityQueue()
{
System.out.println("SSQueue:");
SSQueue<Integer> queue = new
SSQueue<>();
long startTime =
System.nanoTime();
int n = 7;
queue.enqueue(20);
queue.enqueue(50);
queue.enqueue(100);
queue.enqueue(1000);
queue.enqueue(10000);
queue.enqueue(100000);
queue.enqueue(1000000);
for (int i = 0; i < n; i++)
{
queue.enqueue(i
+ n);
queue.dequeue();
}
long endTime =
System.nanoTime();
long totalTime = endTime -
startTime;
System.out.println(n + ", " +
totalTime);
}
/**
* Check efficency of circular queue.
*/
private static void checkEfficencyOfCircularQueue()
{
System.out.println("Circular Array
Queue:");
CircularQueue<Integer> queue
= new CircularQueue<>(1000);
long startTime =
System.nanoTime();
int n = 7;
queue.enqueue(20);
queue.enqueue(50);
queue.enqueue(100);
queue.enqueue(1000);
queue.enqueue(10000);
queue.enqueue(100000);
queue.enqueue(1000000);
for (int i = 0; i < n; i++)
{
queue.enqueue(i
+ n);
queue.dequeue();
}
long endTime =
System.nanoTime();
long totalTime = endTime -
startTime;
System.out.println(n + ", " +
totalTime);
}
}
Output:

[Java] Efficiency Comparison of two Implemented Queues : Circular Array Queue and SSQueue and its enqueue...
PLEASE ANSWER #5AND #6, THE ANSWER FOR #3 AND #4 ARE ALREADY PROVIDED!!! 3 .Using Java, Write a computer program that prompts the user for one number, n for the number of items in the array to sort, and create and sort 1000 arrays of this size timing the run to get an average time to sort an array of this size. Then do the following: Initiate a variable running_time to 0 Create a for loop that iterates 1000 times....
Your running times will probably be different than these. Please
do a better job with the snipping tool than I did.
Java program provided:
// Student Name Today's Date
import java.util.Arrays;
import java.util.Random;
public class SortTimer {
// Please expand method main() to meet the lab
requirements.
// You have the following sorting methods
available:
// insertionSort(int[] a);
// selectionSort(int[] a);
// mergeSort(int[] a);
// quickSort(int[] a);
// The array will be in sorted order after the
routines are called!
...
Copy the following java codes and compile //// HighArray.java //// HighArrayApp.java Study carefully the design and implementation HighArray class and note the attributes and its methods. Create findAll method which uses linear search algorithm to return all number of occurrences of specified element. /** * find an element from array and returns all number of occurrences of the specified element, returns 0 if the element does not exit. * * @param foundElement Element to be found */ int findAll(int...