Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUEUE - java, plz read the Q carefully and i want all the methods & use simple j

ID: 3823448 • Letter: Q

Question

QUEUE - java, plz read the Q carefully and i want all the methods & use simple java language, netbeans 8.1 or 8.2

1. Create a Queue class based on MyLinkedList class. Use this class in the following:

2. Create a new Java Application that has the following methods:

1. A method to generate a number of elements between two given values and save them in a queue

2. A method to print a queue (10 elements per line). The original queue should remain as is after the print

3. A method to return the number of elements on the queue.

4. A method to return if the queue is empty or not.

5. A method to search for a value in a queue. The queue should remain the same after the search is finished.

6. A method to exchange the first element and the last element in a queue (a switch/swap).

7. A method to check if a queue is included in another queue (q1 is included in q2 if q1 is a sub-queue of q2). q1

and q2 should remain as they were originally.

8. A method peekLowestElement to return the smallest element. The original Queue should remain unchanged.

9. A method peekHighestElement to return the largest element. The original Queue should remain unchanged.

10. A method to inverse a queue.

11. A method to make a copy of a queue into a stack (the original queue should remain as is).

• In the main method test all your methods including the following cases:

! Create 2 queues q1 and q2

! Insert 23 integers between 20 and 60 (do not insert duplicates) into q1.

! Insert 35 integers between 10 and 80 (do not insert duplicates) into q2.

Explanation / Answer

1: take two lists and assign values for the list. take the count value into consideration and find the difference between the two lists so that the no of elements between the values can be found. then use bolean add() method to store the values ina queue.

2: int[] n = new int[100];

here this is used to generate 10 elements per line.

4.peek() methos is used to return if the queue is empty. it doesnot delete the items in the queue but returns null if the queue is empty.

5. if a list contains certain values inorder to search for a particular valuee in a list then if value x=10 to be found the if(x==list()) then we can find that particular element is present in the queue.

6.take temporary variable t then values l1 and l2 lists then t=l1; l1=l2; l2=t;

7.Queue q2 = q1.getClass().newInstance();

for(Object e : q1) {

here e is a value to be compared or can be used as an instance

8.peek() method in java is used to return the elements in a queue if queue is not empty.peeklowest() is used to return the lowest element

9.peekhighest() is used to return the highest values in the queue.

10.enqueue() method is used to reverse the elements in the queue.