Question: Please i need help. we are using java, attach comments to help me better understand and a client test code and please use the listNode.java

Please i need help. we are using java, attach comments to help me better understand and a client test code and please use the listNode.java i attached below.

Add a method called split that rearranges the elements of a list so that all of the negative values appear before all of the nonnegatives. For example, suppose a variable list stores the values [8, 7, -4, 19, 0, 43, -8, -7, 2]. The call of list.split(); should rearrange the list to put the negatives first: [-4, -8, -7, 8, 7, 19, 0, 43, 2]. It doesn't matter what order the numbers are in, only that the negatives appear before the nonnegatives, so this is only one possible solution. You must solve the problem by rearranging the links of the list, not by swapping data values or creating new nodes. You also may not use auxiliary structures like arrays or ArrayLists to solve this problem.

*****************************************************************************************************************************************************************

ListNode.java

// ListNode is a class for storing a single node of a linked // list. This node class is for a list of integer values.

public class ListNode { public int data; // data stored in this node public ListNode next; // link to next node in the list

// post: constructs a node with given data and given link public ListNode(int data, ListNode next) { this.data = data; this.next = next; }

// post: constructs a node with given data and null link public ListNode(int data) { this(data, null); }

// post: constructs a node with data 0 and null link public ListNode() { this(0, null); } }

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!