Question: 18/0 Writing Code #1 (20 pts) write a method called rotate Every that accents a list of interers list and an integer nas parameters Your

 18/0 Writing Code #1 (20 pts) write a method called rotate

18/0 Writing Code #1 (20 pts) write a method called rotate Every that accents a list of interers list and an integer nas parameters Your method should rotate every n dieits by 1 index. If the number of elements in the list is not evenly Ovisible by n, the remaining elements should remain in their original locations. For this problem, keep in mind that you are a client of the list, not writing code inside of a list object. Some example calls and their output are below for the list [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) Method Call Resulting List rotate EveryN (list, 3); 12, 0, 1, 5, 3, 4, 8, 6, 7, 9, 101 (3, 0, 1, 2, 7, 4, 5, 6, 8, 9, 10) rotateEveryN (list, 4); rotate EveryN (list, 5); (4, 0, 1, 2, 3, 9, 5, 6, 7, 8, 10) Public void rotate Ivery N (Stack Integer list, intin) { Quere Integer g = New linked list Integers(); inst other size = list size co - no for (int i-o, is other size, itt) f gadd Clist pop()); while Cly is Empty (r list push (gremove (7) while (! list, is Empty () { gadal Clist. pop() while (!y is Emplyc ) list.push (g, remulet)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!