Question: Given is the IntNode class that represents an element in a linked list, and the IntList class that represents a linked list (at the end

Given is the IntNode class that represents an element in a linked list, and the IntList class that represents a linked list (at the end of the question). Add a method signed to the IntList class: public void reverseGroups(int k) The method will receive as a parameter an integer k. The method will reverse any set of k elements from the list. For example, if the list was: head 2 3 1 4 7 5 8 6 null and k = 3 the method will reverse every three members and the list at the end of the method will look like this: Head 1 3 2 5 7 4 6 8 null Note that if there are no k members at the end of the list, the method will reverse the members that are. The method should have a runtime complexity of O(n) and no extra space should be allocated. In particular do not use arrays and strings or assign new lists.

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!