Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Below is the code for the LinkedIntList class that you had for homework 7 . Finish defining the doubleUp method using recursion by writing the
Below is the code for the LinkedIntList class that you had for homework Finish defining the doubleUp method using recursion by writing the code that belongs between the braces for the recursive helper method doubleUpH. The doubleUp method creates a new list that is twice as long and that looks like the original list but with every entry appearing twice in a row duplicated while leaving the original list unchanged. For example, if list contained the numbers then list.doubleUp would create and return a new list that contained and the original list would still have the numbers The only method your code may call is doubleUpH itself and your code must not contain any loops. Solutions that violate either of these restrictions will receive points. Your new code should be completely contained inside the body of the doubleUpH method. If your solution changes the arguments to the doubleUpH method or changes the public doubleUp method, you will receive at most out of the points.
public class LinkedIntList
private class Node
private int item;
private Node next;
public Node
public Nodeint number, Node nextNode
item number;
next nextNode;
private Node first; first node of the list
public LinkedIntList
first null;
Other LinkedIntList methods not listed here for the sake of space
public LinkedIntList doubleUp
LinkedIntList answer new LinkedIntList;
answer.first doubleUpHfirst;
return answer;
private Node doubleUpHNode front
WRITE YOUR CODE HERE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started