Question: Write a method called wrapHalf that accepts a linked list of integers as a parameter and moves the first half of the list to the

Write a method called wrapHalf that accepts a linked list of integers as a parameter and moves the first half of the list to the back of the list. If the list contains an odd number of elements, the smaller half is wrapped (in other words, for a list of size N, the middle element, N/2, becomes the first element in all cases). For example, calling wrapHalf on the list [1, 2, 3, 4, 5, 6] , would change that list into [4, 5, 6, 1, 2, 3] . For the list [5, 6, 7, 8, 9], the result would be [7, 8, 9, 5, 6].

Step by Step Solution

3.32 Rating (167 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public static void wrapHalf LinkedLi... View full answer

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 Building Java Programs A Back to Basics Approach Questions!