Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Question 1: Linked Lists Create an IntLinkedList class, much like the one presented in class. It should implement a linked list that will hold values

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Question 1: Linked Lists Create an IntLinkedList class, much like the one presented in class. It should implement a linked list that will hold values of type int. It should use an IntNode class to implement the nodes in the linked list. The linked list must have the following methods: A constructor with no parameters which creates an empty list void add (int data) adds data to the front of the list. A constructor IntLinkedList(intl ]) which will create a linked list containing the same values as the int ] array, and in the same order. void remove(int index)-remove one node from the list, at the specified index, starting at 0. If the index is invalid, remove nothing. .String toString-ren a String containing the integer values, in the order they appear in the list, with > surrounding them, and commas separating them. There should not be a comma after the last integer. For example, > not ) boolean empty)-returns true if the list is empty, and false otherwise. IntLinkedList clone)- return a deep copy of the linked list, with a new set of nodes. The data should be in the same order as the data in the original list. For full marks, your code must be efficient, and must not go through the nodes of any list more than once. Question 2: Recursion with Linked Lists Add the following methods to the linked list class created above. These problems must be solved using recursion where indicated Add an instance method void add (IntNode) which will add an existing node to the front of a linked list. It should not create a new node. This will not be recursive. This method should be used by the split method, below. Define an instance method void split(IntLinkedList odds, IntLinkedList evens) which will remove all of the nodes from a linked list, and add them to two other lists, odds and evens, depending on Page 1 of 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions