Write a method reversefirstk that accepts an integer k and


I tried to answer this but nothing, if someone knows please help!

Program- Write a method reverseFirstK that accepts an integer k and a queue of integers as parameters and reverses the order of the first k elements of the queue, leaving the other elements in the same relative order.

For case, suppose a variable q stores the subsequent elements:

front [10, 20, 30, 40, 50, 60, 70, 80, 90] back

The call of reverseFirstK(4, q); should change the queue to store the following elements in this order:

front [40, 30, 20, 10, 50, 60, 70, 80, 90] back If k is 0 or negative, no change should be made to the queue. If the queue passed is null or does not contain at least k elements, your method should throw an IllegalArgumentException.

Can you provide some help with my java language project? I hope someone nice out there can help me with it.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Write a method reversefirstk that accepts an integer k and
Reference No:- TGS0965360

Expected delivery within 24 Hours