1. Write a method "int GetSecondMax(int[] array)" . this method takes an array of integers and returns the second max value

Example: if the array contains: 7, 2, 9, 5, 4, 15, 6, 1}. It should return the value: 9

2. Write a method "removeEvensArrayList" that takes an ArrayList of integers. This method is to remove all the even values between 40 and 60 from the list

3. Write a method "removeEvensQueue" that takes a queue (type: interface Queue) of integers. This method should remove all the even values from it and keep all the rest (odd numbers) in the queue in the same order they were before

4. Write a method "removeOdds" that takes a stack (type: Deque) of integers. This method should remove all the odd values and leave the even values in the stack in the same original order.

5. Write a method "rotate" that takes a java LinkedList of integers as a parameter and an integer variable 'count' to represent the number of rotations. This method is to rotate the LinkedList count number of times counterclockwise (considering the head is on the left, tail on the right.

6. Write a method "mergeQueueStack" that takes a queue as a parameter of type: Queue of integers and a stack as a second parameter of type: Deque of integers

Remove all the items from the queue and remove all the items from the stack then add them to a LinkedList by alternating between an item from queue then an item from stack.

Don't assume initially both the queue and the stack have the same number of items. The method should return the linked list of type integers.

Example:

If queue has : 1,2,3,4,5 and stack has 10, 20, 30 (where 10 is at top of the stack) then the linkedList should contain: 1,10,2,20,3,3,4,5

7. Write a method "removeBottomItemStack" that takes a stack of integers and removes the first item added (the one at the bottom).

8. Write a method "removeHighestLinkedList" that takes a LinkedList and removes the highest value.

9. Write a method "reverseOrderQueue" that takes a queue of integers (Queue type), then it reverses its content

10. Write code in Main to call and test these methods (question 1 to 9)

Note:

The terms Stack and Queue are the general traditional terms. Use the appropriate Interfaces and classes as defined in java.

For the Queue use the java interface Queue with the ArrayDeque class

For the Stack use the java Deque interface with the ArrayDeque class

For the LinkedList, use the java LinkedList class

Also, when you are asked to create and use a Queue, you can use only those methods pertaining to the general operations of a queue (Enqueue: addLast, Dequeue: removeFirst, and peek()

Similarly, when you are asked to create and/or use a stack, you can use only those methods pertaining to the general operations of a Stack (push: addFirst, pop:removeFirst, and peek() )

Your code should not only do the job, but also it should be done as efficiently as possible: fast and uses no additional memory if at all possible.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.