Question: I am currently learning about LinkedList, and need help completing these few questions to make sure I am doing them correct. Any help is appreciated,

I am currently learning about LinkedList, and need help completing these few questions to make sure I am doing them correct. Any help is appreciated, and I will leave a positive review!

Programs Needed to complete these questions -

ListNode:

public class ListNode implements Linkable { private Comparable listNodeValue; private ListNode nextListNode; public ListNode() { listNodeValue = null; nextListNode = null; } public ListNode(Comparable value, ListNode next) { listNodeValue=value; nextListNode=next; } public Comparable getValue() { return listNodeValue; } public ListNode getNext() { return nextListNode; } public void setValue(Comparable value) { listNodeValue = value; } public void setNext(Linkable next) { nextListNode = (ListNode)next; } }

Linkable:

public interface Linkable { Comparable getValue(); Linkable getNext(); void setNext(Linkable next); void setValue(Comparable value); }

1. What order would the values go in the boxes below?

I am currently learning about LinkedList, and need help completing these few

2. What order would the values go in the boxes below?

questions to make sure I am doing them correct. Any help is

3. Complete method countOdds().

appreciated, and I will leave a positive review! Programs Needed to complete

4. Complete method skipEveryOther().

these questions - ListNode: public class ListNode implements Linkable { private Comparable5. Complete method doubleUp().

listNodeValue; private ListNode nextListNode; public ListNode() { listNodeValue = null; nextListNode =6. Complete method countNodes().

null; } public ListNode(Comparable value, ListNode next) { listNodeValue=value; nextListNode=next; } public7. Complete method doubleFront().

Comparable getValue() { return listNodeValue; } public ListNode getNext() { return nextListNode;} public void setValue(Comparable value) { listNodeValue = value; } public void

ListNode front = null, back = null; for (int i=0; i 5 -> 3 -> 4 -> 7 -> null //list after call to skip 1 -> 3 -> 7 -> null \/method doubleUp will double the size of the list by adding in lew nodes with the same values as the original list nodes public void doubleUp (ListNode list) Example 1/original list 1 -> 4 -> null //list after call to double 1 -> 1 -> 4 -> 4 -> null private ListNode theList; //instance variable / data field //method countNodes will count the number of nodes present in the list public int countNodes () { Example //original list 1 -> 5 -> 3 -> 4 -> 7 -> null //retun value of countNodes 5 } private ListNode theList; //instance variable / data field Example l/method doubleFront will add a new node at the front of the list with // the same value as the current node at the front of the list public void doubleFront () { //original list 1 - 4 -> null } //list after call to double 1 -> 1 - 4 -> null private ListNode theList; //instance variable Example 1/method removeNode will remove the 1" occurrence of obj public void removeNode (Object obj) { 1/original list 1 -> 5 -> 3 -> 4 -> 7 -> null //value to remove 5 1/original list after remove 1 -> 3 -> 4 -> 7 -> 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!