Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions

Question

Who was the first woman prime minister of india?

Answered: 1 week ago

Question

Explain the concept of going concern value in detail.

Answered: 1 week ago

Question

Define marketing.

Answered: 1 week ago

Question

What are the traditional marketing concepts? Explain.

Answered: 1 week ago

Question

Recognize the power of service guarantees.

Answered: 1 week ago

Question

Demonstrate how to use the Gaps Model for diagnosing and

Answered: 1 week ago