SlideShare a Scribd company logo
1 of 4
Download to read offline
Note: Can someone help me with the Public boolean add(E value) method and Private void
add(E value,Node n) method. I have everything but it is not working. Also need help with the
remove methods. Both public and private methods for remove. package edu.ust.cisc; import
java.util.Iterator; import java.util.NoSuchElementException; public class CiscSortedLinkedList
> implements CiscList { /** * A reference to this list's dummy node. Its next reference should
refer to the node containing the first element * in this list, or it should refer to itself if the list is
empty. The next reference within the node containing * the last element in this list should refer to
dummy, thus creating a cyclic list. */ private Node dummy; /** * Number of elements in the list.
*/ private int size; /** * Constructs an empty CiscSortedLinkedList instance with a non-null
dummy node whose next reference refers to * itself. */ public CiscSortedLinkedList() { dummy
= new Node<>(null, null); dummy.next = dummy; } /** * Returns the number of elements in
this list. * * @return the number of elements in this list */ @Override public int size() { return
size; } /** * Returns {@code true} if this list contains no elements. * * @return {@code true} if
this list contains no elements */ @Override public boolean isEmpty() { return size==0; } /** *
Returns {@code true} if this list contains the specified element (compared using the {@code
equals} method). * This implementation should stop searching as soon as it is able to determine
that the specified element is not * present. * @param o element whose presence in this list is to
be tested * @return {@code true} if this list contains the specified element * @throws
NullPointerException if the specified element is null */ @Override public boolean
contains(Object o) { if(o==null){ throw new NullPointerException(); } return
containsHelper(o,dummy.next); } private boolean containsHelper(Object o, Node node){
if(node== dummy){ return false; } else if(o.equals(node.data)){ return true; } else{ return
containsHelper(o,node.next); } } /** * Returns an iterator over the elements in this list in proper
sequence. * * @return an iterator over the elements in this list in proper sequence */ @Override
public Iterator iterator() { //return new Iterator (){ //private Node curr = dummy.next; //private
Node prev = dummy; //private boolean canRemove = false; return new CiscLinkedListIterator();
} /** * Returns an array containing all of the elements in this list in proper sequence (from first
to last element). * *
The returned array will be "safe" in that no references to it are maintained by this list. (In other
words, * this method must allocate a new array even if this list is backed by an array). The caller
is thus free to modify * the returned array. * * @return an array containing all of the elements in
this list in proper sequence */ @Override public Object[] toArray() { Object[] arr = new
Object[size]; int i = 0; for(Node current = dummy;current!=null;current= current.next){ arr[i++]
= current.data; } return arr; } /** * {@link #toArray} recursive helper method. Adds the element
contained in the specified node to the specified index * in the specified array. Recursion stops
when the specified node is the dummy node. * * @param arr the array into which each element
in this list should be added * @param index the index into which the next element in this list
should be added * @param n the node containing the next element in this list to add to the array
*/ private void toArray(Object[] arr, int index, Node n) { } /** * Adds the specified element to
its sorted location in this list. * *
Lists may place the specified element at arbitrary locations if desired. In particular, an ordered
list will * insert the specified element at its sorted location. List classes should clearly specify in
their documentation * how elements will be added to the list if different from the default
behavior (end of this list). * * @param value element to be added to this list * @return {@code
true} * @throws NullPointerException if the specified element is null */ @Override public
boolean add(E value) { if(value==null){ throw new NullPointerException(); } Node newNode =
Node(value); return false; } /** * {@link #add} recursive helper method. Adds the specified
value to the list in a new node following the specified * node (if that is the appropriate location
in the list). * * @param value element to be added to this list * @param n a reference to the node
possibly prior to the one created by this method */ private void add(E value, Node n) { } /** *
Removes the first occurrence of the specified element from this list, if it is present. If this list
does not * contain the element, it is unchanged. Returns {@code true} if this list contained the
specified element. This * implementation should stop searching as soon as it is able to determine
that the specified element is not * present. * * @param o element to be removed from this list, if
present * @return {@code true} if this list contained the specified element * @throws
NullPointerException if the specified element is null */ @Override public boolean
remove(Object o) { if(o==null){ throw new NullPointerException(); } Node curr = dummy.next;
Node prev = dummy; while (curr != dummy && !o.equals(curr.data)) { prev = curr; curr =
curr.next; } if (curr == dummy) { return false; } else { System.out.println("Removing
Data:"+curr.data); prev.next = curr.next; size--; return true; } } /** * {@link #remove} recursive
helper method. Removes the node following n if it contains the specified element. This *
implementation should stop searching as soon as it is able to determine that the specified element
is not * present. * * @param o element to be removed from this list, if present * @param n a
reference to the node prior to the one possibly containing the value to remove * @return */
private boolean remove(Object o, Node n) { return false; } /** * Removes all of the elements
from this list. The list will be empty after this call returns. @Override public void clear() {
dummy.next=dummy; size=0; } /** * Returns the element at the specified position in this list. *
* @param index index of the element to return * @return the element at the specified position in
this list * @throws IndexOutOfBoundsException if the index is out of range */ @Override
public E get(int index) { if (index < 0 || index >= size) { throw new
IndexOutOfBoundsException(); } return get(index, 0, dummy.next); //if (index < 0 || index >=
size) { //throw new IndexOutOfBoundsException(); } //return null; /** * {@link #get} recursive
helper method. Returns the element contained within the node parameter whose index * matches
the specified index. * * @param index index of the element to return * @param currentIndex the
index of the node parameter * @param n the node containing the element at currentIndex *
@return the element at the specified position (index) in this list */ private E get(int index, int
currentIndex, Node n){ if (currentIndex == index) { return n.data; } return get(index,
currentIndex + 1, n.next); //return null; } /** * This operation is not supported by
CiscSortedLinkedList. * * @param index index of the element to replace * @param element
element to be stored at the specified position * @return the element previously at the specified
position * @throws UnsupportedOperationException if the {@code set} operation is not
supported by this list */ @Override public E set(int index, E element) { throw new
UnsupportedOperationException(); } /** * This operation is not supported by
CiscSortedLinkedList. * * @param index index at which the specified element is to be inserted *
@param element element to be inserted * @throws UnsupportedOperationException if the
{@code set} operation is not supported by this list */ @Override public void add(int index, E
element) { if(!add(element)){ throw new UnsupportedOperationException(); } } /** * Appends
all elements in the specified list to the end of this list, in the order that they are returned by the *
specified list's iterator. * * @param c list containing elements to be added to this list * @return
{@code true} if this list changed as a result of the call * @throws NullPointerException if the
specified list is null */ @Override public boolean addAll(CiscList extends E> c) { if(c==null){
throw new NullPointerException(); } return false; } /** * Removes the element at the specified
position in this list. Shifts any subsequent elements to the left * (subtracts one from their
indices). Returns the element that was removed from the list. * * @param index the index of the
element to be removed * @return the element previously at the specified position * @throws
IndexOutOfBoundsException if the index is out of range */ @Override public E remove(int
index) { if(index<0 || index>size){ throw new IndexOutOfBoundsException(); } return null; }
/** * {@link #remove} recursive helper method. Removes the node following n if it contains the
element at the specified * index. * * @param index the index of the element to be removed *
@param currentIndex the index of the node parameter * @param n the node containing the
element at currentIndex * @return */ private E remove(int index, int currentIndex, Node n) {
return null; } /** * Returns the index of the first occurrence of the specified element in this list,
or -1 if this list does not * contain the element (compared using the {@code equals} method).
This implementation should stop searching as * soon as it is able to determine that the specified
element is not present. * * @param o element to search for * @return the index of the first
occurrence of the specified element in this list, or -1 if this list does not * contain the element *
@throws NullPointerException if the specified element is null */ @Override public int
indexOf(Object o) { if(o==null){ throw new NullPointerException(); } return indexOf(o,0,
dummy.next); } /** * {@link #indexOf} recursive helper method. Returns currentIndex if the
element contained in the node parameter is * equal to the specified element to search for. This
implementation should stop searching as soon as it is able to * determine that the specified
element is not present. * * @param o element to search for * @param currentIndex the index of
the node parameter * @param n the node containing the element at currentIndex * @return the
index of the first occurrence of the specified element in this list, or -1 if this list does not *
contain the element */ private int indexOf(Object o, int currentIndex, Node n) {
if(n.data.equals(o)){ return currentIndex; } else if(n==dummy){ return -1; } else
if(n.data.compareTo((E)o)>0){ return -1; } else{ return indexOf(o,currentIndex+1,n.next); } }
/** * Returns a string representation of this list. This string should consist of a comma separated
list of values * contained in this list, in order, surrounded by square brackets (examples: [3, 6, 7]
and []). * * @return a string representation of this list */ public String toString() { return null; }
/** * {@link #toString} recursive helper method. Returns a string representation of this list,
beginning with the * element in the specified node * * @param n the node containing the next
element to append to the string * @return a string representation of this list, beginning with the
element in the specified node */ private String toString(Node n) { return null; } private static
class Node { private E data; private Node next; private Node(E data, Node next) { this.data =
data; this.next = next; } } private class CiscLinkedListIterator implements Iterator { /** * A
reference to the node containing the next element to return, or to the dummy node if there are no
more * elements to return. */ private Node nextNode; /** * Constructs an iterator ready to return
the first element in the list (if present). */ public CiscLinkedListIterator() {
nextNode=dummy.next; } /** * Returns {@code true} if the iteration has more elements. (In
other words, returns {@code true} if * {@link #next} would return an element rather than
throwing an exception.) * * @return {@code true} if the iteration has more elements */
@Override public boolean hasNext() { return nextNode!=dummy && nextNode!=null; } /** *
Returns the next element in the iteration. * * @return the next element in the iteration * @throws
NoSuchElementException if the iteration has no more elements */ @Override public E next() {
if(!hasNext()){ throw new NoSuchElementException(); } E data=nextNode.data;
nextNode=nextNode.next; return data; } } }

More Related Content

Similar to Note- Can someone help me with the Public boolean add(E value) method.pdf

import java.util.Iterator; import java.util.NoSuchElementException; .pdf
  import java.util.Iterator; import java.util.NoSuchElementException; .pdf  import java.util.Iterator; import java.util.NoSuchElementException; .pdf
import java.util.Iterator; import java.util.NoSuchElementException; .pdfdeepakangel
 
For this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdfFor this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdffashiongallery1
 
Implementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfImplementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfmaheshkumar12354
 
we using java code DynamicArrayjava Replace all .pdf
we using java code   DynamicArrayjava   Replace all .pdfwe using java code   DynamicArrayjava   Replace all .pdf
we using java code DynamicArrayjava Replace all .pdfgudduraza28
 
public class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdfpublic class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdfaccostinternational
 
Lecture 18Dynamic Data Structures and Generics (II).docx
Lecture 18Dynamic Data Structures and Generics (II).docxLecture 18Dynamic Data Structures and Generics (II).docx
Lecture 18Dynamic Data Structures and Generics (II).docxSHIVA101531
 
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdfImplement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdfrishabjain5053
 
please read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdfplease read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdfaggarwalopticalsco
 
package linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdfpackage linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdfarcellzone
 
Implement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfImplement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfudit652068
 
we using java dynamicArray package modellinearpub imp.pdf
we using java dynamicArray    package modellinearpub   imp.pdfwe using java dynamicArray    package modellinearpub   imp.pdf
we using java dynamicArray package modellinearpub imp.pdfadityagupta3310
 
Given below is the completed implementation of MyLinkedList class. O.pdf
Given below is the completed implementation of MyLinkedList class. O.pdfGiven below is the completed implementation of MyLinkedList class. O.pdf
Given below is the completed implementation of MyLinkedList class. O.pdfinfo430661
 
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdfDividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdftesmondday29076
 
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdfLabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdffantasiatheoutofthef
 
Please do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdfPlease do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdfaioils
 
Describe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdfDescribe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdfdeepak596396
 
please read below it will tell you what we are using L.pdf
please read below it will tell you what we are using   L.pdfplease read below it will tell you what we are using   L.pdf
please read below it will tell you what we are using L.pdfankit11134
 
Java Foundations StackADT-java --- - Defines the interface to a stack.docx
Java Foundations StackADT-java ---  - Defines the interface to a stack.docxJava Foundations StackADT-java ---  - Defines the interface to a stack.docx
Java Foundations StackADT-java --- - Defines the interface to a stack.docxVictorXUQGloverl
 
please i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdfplease i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdfezonesolutions
 
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdfpackage com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdfaptind
 

Similar to Note- Can someone help me with the Public boolean add(E value) method.pdf (20)

import java.util.Iterator; import java.util.NoSuchElementException; .pdf
  import java.util.Iterator; import java.util.NoSuchElementException; .pdf  import java.util.Iterator; import java.util.NoSuchElementException; .pdf
import java.util.Iterator; import java.util.NoSuchElementException; .pdf
 
For this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdfFor this lab you will complete the class MyArrayList by implementing.pdf
For this lab you will complete the class MyArrayList by implementing.pdf
 
Implementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdfImplementation The starter code includes List.java. You should not c.pdf
Implementation The starter code includes List.java. You should not c.pdf
 
we using java code DynamicArrayjava Replace all .pdf
we using java code   DynamicArrayjava   Replace all .pdfwe using java code   DynamicArrayjava   Replace all .pdf
we using java code DynamicArrayjava Replace all .pdf
 
public class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdfpublic class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdf
 
Lecture 18Dynamic Data Structures and Generics (II).docx
Lecture 18Dynamic Data Structures and Generics (II).docxLecture 18Dynamic Data Structures and Generics (II).docx
Lecture 18Dynamic Data Structures and Generics (II).docx
 
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdfImplement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
 
please read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdfplease read the steps below and it will tell you what we usi.pdf
please read the steps below and it will tell you what we usi.pdf
 
package linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdfpackage linkedLists- import java-util-Iterator- --- A class representi.pdf
package linkedLists- import java-util-Iterator- --- A class representi.pdf
 
Implement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfImplement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdf
 
we using java dynamicArray package modellinearpub imp.pdf
we using java dynamicArray    package modellinearpub   imp.pdfwe using java dynamicArray    package modellinearpub   imp.pdf
we using java dynamicArray package modellinearpub imp.pdf
 
Given below is the completed implementation of MyLinkedList class. O.pdf
Given below is the completed implementation of MyLinkedList class. O.pdfGiven below is the completed implementation of MyLinkedList class. O.pdf
Given below is the completed implementation of MyLinkedList class. O.pdf
 
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdfDividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
 
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdfLabProgram.javaimport java.util.NoSuchElementException;public .pdf
LabProgram.javaimport java.util.NoSuchElementException;public .pdf
 
Please do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdfPlease do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdf
 
Describe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdfDescribe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdf
 
please read below it will tell you what we are using L.pdf
please read below it will tell you what we are using   L.pdfplease read below it will tell you what we are using   L.pdf
please read below it will tell you what we are using L.pdf
 
Java Foundations StackADT-java --- - Defines the interface to a stack.docx
Java Foundations StackADT-java ---  - Defines the interface to a stack.docxJava Foundations StackADT-java ---  - Defines the interface to a stack.docx
Java Foundations StackADT-java --- - Defines the interface to a stack.docx
 
please i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdfplease i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdf
 
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdfpackage com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
 

More from Stewart29UReesa

Note- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdf
Note- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdfNote- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdf
Note- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdfStewart29UReesa
 
need in c language Write a function called isIsoceles that accepts thr.pdf
need in c language Write a function called isIsoceles that accepts thr.pdfneed in c language Write a function called isIsoceles that accepts thr.pdf
need in c language Write a function called isIsoceles that accepts thr.pdfStewart29UReesa
 
need in c language Write the body of a function called sumRange that a.pdf
need in c language Write the body of a function called sumRange that a.pdfneed in c language Write the body of a function called sumRange that a.pdf
need in c language Write the body of a function called sumRange that a.pdfStewart29UReesa
 
Need help with this ASAP- This is Database systems- Please draw out th.pdf
Need help with this ASAP- This is Database systems- Please draw out th.pdfNeed help with this ASAP- This is Database systems- Please draw out th.pdf
Need help with this ASAP- This is Database systems- Please draw out th.pdfStewart29UReesa
 
Nheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdf
Nheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdfNheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdf
Nheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdfStewart29UReesa
 
Nikke has just received an amended assessment from the Australian Taxa.pdf
Nikke has just received an amended assessment from the Australian Taxa.pdfNikke has just received an amended assessment from the Australian Taxa.pdf
Nikke has just received an amended assessment from the Australian Taxa.pdfStewart29UReesa
 
Orange- Below is a sequence alignment with fixed differences for speci.pdf
Orange- Below is a sequence alignment with fixed differences for speci.pdfOrange- Below is a sequence alignment with fixed differences for speci.pdf
Orange- Below is a sequence alignment with fixed differences for speci.pdfStewart29UReesa
 
Nordic Multinationals Nordic countries have small populations ( 6 mill.pdf
Nordic Multinationals Nordic countries have small populations ( 6 mill.pdfNordic Multinationals Nordic countries have small populations ( 6 mill.pdf
Nordic Multinationals Nordic countries have small populations ( 6 mill.pdfStewart29UReesa
 
Nordic countries have small populations (6 million in Denmark- 9 milli.pdf
Nordic countries have small populations (6 million in Denmark- 9 milli.pdfNordic countries have small populations (6 million in Denmark- 9 milli.pdf
Nordic countries have small populations (6 million in Denmark- 9 milli.pdfStewart29UReesa
 
Ontinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdf
Ontinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdfOntinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdf
Ontinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdfStewart29UReesa
 
One of the concerns in severe ankle sprain is that the patient has sus.pdf
One of the concerns in severe ankle sprain is that the patient has sus.pdfOne of the concerns in severe ankle sprain is that the patient has sus.pdf
One of the concerns in severe ankle sprain is that the patient has sus.pdfStewart29UReesa
 
no more info Given the system represented by the equations- x1-x22x13.pdf
no more info  Given the system represented by the equations- x1-x22x13.pdfno more info  Given the system represented by the equations- x1-x22x13.pdf
no more info Given the system represented by the equations- x1-x22x13.pdfStewart29UReesa
 
On June 13- the board of directors of Siewert Incorporated declared a.pdf
On June 13- the board of directors of Siewert Incorporated declared a.pdfOn June 13- the board of directors of Siewert Incorporated declared a.pdf
On June 13- the board of directors of Siewert Incorporated declared a.pdfStewart29UReesa
 
On May 1- 2023- Romy and Vic formed a partnership contributing assets.pdf
On May 1- 2023- Romy and Vic formed a partnership contributing assets.pdfOn May 1- 2023- Romy and Vic formed a partnership contributing assets.pdf
On May 1- 2023- Romy and Vic formed a partnership contributing assets.pdfStewart29UReesa
 
On January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdf
On January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdfOn January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdf
On January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdfStewart29UReesa
 
need asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdf
need asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdfneed asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdf
need asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdfStewart29UReesa
 
On December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdf
On December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdfOn December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdf
On December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdfStewart29UReesa
 
On December 10- YR08 the board of directors of Apple Inc- declared a c.pdf
On December 10- YR08 the board of directors of Apple Inc- declared a c.pdfOn December 10- YR08 the board of directors of Apple Inc- declared a c.pdf
On December 10- YR08 the board of directors of Apple Inc- declared a c.pdfStewart29UReesa
 
Objective- Write syntactically correct while-for loops Given a list of.pdf
Objective- Write syntactically correct while-for loops Given a list of.pdfObjective- Write syntactically correct while-for loops Given a list of.pdf
Objective- Write syntactically correct while-for loops Given a list of.pdfStewart29UReesa
 
Observe the Psilotum photos above- and the fern photos below- On what.pdf
Observe the Psilotum photos above- and the fern photos below- On what.pdfObserve the Psilotum photos above- and the fern photos below- On what.pdf
Observe the Psilotum photos above- and the fern photos below- On what.pdfStewart29UReesa
 

More from Stewart29UReesa (20)

Note- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdf
Note- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdfNote- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdf
Note- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdf
 
need in c language Write a function called isIsoceles that accepts thr.pdf
need in c language Write a function called isIsoceles that accepts thr.pdfneed in c language Write a function called isIsoceles that accepts thr.pdf
need in c language Write a function called isIsoceles that accepts thr.pdf
 
need in c language Write the body of a function called sumRange that a.pdf
need in c language Write the body of a function called sumRange that a.pdfneed in c language Write the body of a function called sumRange that a.pdf
need in c language Write the body of a function called sumRange that a.pdf
 
Need help with this ASAP- This is Database systems- Please draw out th.pdf
Need help with this ASAP- This is Database systems- Please draw out th.pdfNeed help with this ASAP- This is Database systems- Please draw out th.pdf
Need help with this ASAP- This is Database systems- Please draw out th.pdf
 
Nheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdf
Nheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdfNheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdf
Nheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdf
 
Nikke has just received an amended assessment from the Australian Taxa.pdf
Nikke has just received an amended assessment from the Australian Taxa.pdfNikke has just received an amended assessment from the Australian Taxa.pdf
Nikke has just received an amended assessment from the Australian Taxa.pdf
 
Orange- Below is a sequence alignment with fixed differences for speci.pdf
Orange- Below is a sequence alignment with fixed differences for speci.pdfOrange- Below is a sequence alignment with fixed differences for speci.pdf
Orange- Below is a sequence alignment with fixed differences for speci.pdf
 
Nordic Multinationals Nordic countries have small populations ( 6 mill.pdf
Nordic Multinationals Nordic countries have small populations ( 6 mill.pdfNordic Multinationals Nordic countries have small populations ( 6 mill.pdf
Nordic Multinationals Nordic countries have small populations ( 6 mill.pdf
 
Nordic countries have small populations (6 million in Denmark- 9 milli.pdf
Nordic countries have small populations (6 million in Denmark- 9 milli.pdfNordic countries have small populations (6 million in Denmark- 9 milli.pdf
Nordic countries have small populations (6 million in Denmark- 9 milli.pdf
 
Ontinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdf
Ontinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdfOntinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdf
Ontinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdf
 
One of the concerns in severe ankle sprain is that the patient has sus.pdf
One of the concerns in severe ankle sprain is that the patient has sus.pdfOne of the concerns in severe ankle sprain is that the patient has sus.pdf
One of the concerns in severe ankle sprain is that the patient has sus.pdf
 
no more info Given the system represented by the equations- x1-x22x13.pdf
no more info  Given the system represented by the equations- x1-x22x13.pdfno more info  Given the system represented by the equations- x1-x22x13.pdf
no more info Given the system represented by the equations- x1-x22x13.pdf
 
On June 13- the board of directors of Siewert Incorporated declared a.pdf
On June 13- the board of directors of Siewert Incorporated declared a.pdfOn June 13- the board of directors of Siewert Incorporated declared a.pdf
On June 13- the board of directors of Siewert Incorporated declared a.pdf
 
On May 1- 2023- Romy and Vic formed a partnership contributing assets.pdf
On May 1- 2023- Romy and Vic formed a partnership contributing assets.pdfOn May 1- 2023- Romy and Vic formed a partnership contributing assets.pdf
On May 1- 2023- Romy and Vic formed a partnership contributing assets.pdf
 
On January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdf
On January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdfOn January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdf
On January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdf
 
need asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdf
need asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdfneed asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdf
need asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdf
 
On December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdf
On December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdfOn December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdf
On December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdf
 
On December 10- YR08 the board of directors of Apple Inc- declared a c.pdf
On December 10- YR08 the board of directors of Apple Inc- declared a c.pdfOn December 10- YR08 the board of directors of Apple Inc- declared a c.pdf
On December 10- YR08 the board of directors of Apple Inc- declared a c.pdf
 
Objective- Write syntactically correct while-for loops Given a list of.pdf
Objective- Write syntactically correct while-for loops Given a list of.pdfObjective- Write syntactically correct while-for loops Given a list of.pdf
Objective- Write syntactically correct while-for loops Given a list of.pdf
 
Observe the Psilotum photos above- and the fern photos below- On what.pdf
Observe the Psilotum photos above- and the fern photos below- On what.pdfObserve the Psilotum photos above- and the fern photos below- On what.pdf
Observe the Psilotum photos above- and the fern photos below- On what.pdf
 

Recently uploaded

UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MysoreMuleSoftMeetup
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfJerry Chew
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaEADTU
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 

Note- Can someone help me with the Public boolean add(E value) method.pdf

  • 1. Note: Can someone help me with the Public boolean add(E value) method and Private void add(E value,Node n) method. I have everything but it is not working. Also need help with the remove methods. Both public and private methods for remove. package edu.ust.cisc; import java.util.Iterator; import java.util.NoSuchElementException; public class CiscSortedLinkedList > implements CiscList { /** * A reference to this list's dummy node. Its next reference should refer to the node containing the first element * in this list, or it should refer to itself if the list is empty. The next reference within the node containing * the last element in this list should refer to dummy, thus creating a cyclic list. */ private Node dummy; /** * Number of elements in the list. */ private int size; /** * Constructs an empty CiscSortedLinkedList instance with a non-null dummy node whose next reference refers to * itself. */ public CiscSortedLinkedList() { dummy = new Node<>(null, null); dummy.next = dummy; } /** * Returns the number of elements in this list. * * @return the number of elements in this list */ @Override public int size() { return size; } /** * Returns {@code true} if this list contains no elements. * * @return {@code true} if this list contains no elements */ @Override public boolean isEmpty() { return size==0; } /** * Returns {@code true} if this list contains the specified element (compared using the {@code equals} method). * This implementation should stop searching as soon as it is able to determine that the specified element is not * present. * @param o element whose presence in this list is to be tested * @return {@code true} if this list contains the specified element * @throws NullPointerException if the specified element is null */ @Override public boolean contains(Object o) { if(o==null){ throw new NullPointerException(); } return containsHelper(o,dummy.next); } private boolean containsHelper(Object o, Node node){ if(node== dummy){ return false; } else if(o.equals(node.data)){ return true; } else{ return containsHelper(o,node.next); } } /** * Returns an iterator over the elements in this list in proper sequence. * * @return an iterator over the elements in this list in proper sequence */ @Override public Iterator iterator() { //return new Iterator (){ //private Node curr = dummy.next; //private Node prev = dummy; //private boolean canRemove = false; return new CiscLinkedListIterator(); } /** * Returns an array containing all of the elements in this list in proper sequence (from first to last element). * * The returned array will be "safe" in that no references to it are maintained by this list. (In other words, * this method must allocate a new array even if this list is backed by an array). The caller is thus free to modify * the returned array. * * @return an array containing all of the elements in this list in proper sequence */ @Override public Object[] toArray() { Object[] arr = new Object[size]; int i = 0; for(Node current = dummy;current!=null;current= current.next){ arr[i++] = current.data; } return arr; } /** * {@link #toArray} recursive helper method. Adds the element contained in the specified node to the specified index * in the specified array. Recursion stops when the specified node is the dummy node. * * @param arr the array into which each element in this list should be added * @param index the index into which the next element in this list should be added * @param n the node containing the next element in this list to add to the array */ private void toArray(Object[] arr, int index, Node n) { } /** * Adds the specified element to its sorted location in this list. * * Lists may place the specified element at arbitrary locations if desired. In particular, an ordered list will * insert the specified element at its sorted location. List classes should clearly specify in their documentation * how elements will be added to the list if different from the default behavior (end of this list). * * @param value element to be added to this list * @return {@code
  • 2. true} * @throws NullPointerException if the specified element is null */ @Override public boolean add(E value) { if(value==null){ throw new NullPointerException(); } Node newNode = Node(value); return false; } /** * {@link #add} recursive helper method. Adds the specified value to the list in a new node following the specified * node (if that is the appropriate location in the list). * * @param value element to be added to this list * @param n a reference to the node possibly prior to the one created by this method */ private void add(E value, Node n) { } /** * Removes the first occurrence of the specified element from this list, if it is present. If this list does not * contain the element, it is unchanged. Returns {@code true} if this list contained the specified element. This * implementation should stop searching as soon as it is able to determine that the specified element is not * present. * * @param o element to be removed from this list, if present * @return {@code true} if this list contained the specified element * @throws NullPointerException if the specified element is null */ @Override public boolean remove(Object o) { if(o==null){ throw new NullPointerException(); } Node curr = dummy.next; Node prev = dummy; while (curr != dummy && !o.equals(curr.data)) { prev = curr; curr = curr.next; } if (curr == dummy) { return false; } else { System.out.println("Removing Data:"+curr.data); prev.next = curr.next; size--; return true; } } /** * {@link #remove} recursive helper method. Removes the node following n if it contains the specified element. This * implementation should stop searching as soon as it is able to determine that the specified element is not * present. * * @param o element to be removed from this list, if present * @param n a reference to the node prior to the one possibly containing the value to remove * @return */ private boolean remove(Object o, Node n) { return false; } /** * Removes all of the elements from this list. The list will be empty after this call returns. @Override public void clear() { dummy.next=dummy; size=0; } /** * Returns the element at the specified position in this list. * * @param index index of the element to return * @return the element at the specified position in this list * @throws IndexOutOfBoundsException if the index is out of range */ @Override public E get(int index) { if (index < 0 || index >= size) { throw new IndexOutOfBoundsException(); } return get(index, 0, dummy.next); //if (index < 0 || index >= size) { //throw new IndexOutOfBoundsException(); } //return null; /** * {@link #get} recursive helper method. Returns the element contained within the node parameter whose index * matches the specified index. * * @param index index of the element to return * @param currentIndex the index of the node parameter * @param n the node containing the element at currentIndex * @return the element at the specified position (index) in this list */ private E get(int index, int currentIndex, Node n){ if (currentIndex == index) { return n.data; } return get(index, currentIndex + 1, n.next); //return null; } /** * This operation is not supported by CiscSortedLinkedList. * * @param index index of the element to replace * @param element element to be stored at the specified position * @return the element previously at the specified position * @throws UnsupportedOperationException if the {@code set} operation is not supported by this list */ @Override public E set(int index, E element) { throw new UnsupportedOperationException(); } /** * This operation is not supported by CiscSortedLinkedList. * * @param index index at which the specified element is to be inserted * @param element element to be inserted * @throws UnsupportedOperationException if the {@code set} operation is not supported by this list */ @Override public void add(int index, E element) { if(!add(element)){ throw new UnsupportedOperationException(); } } /** * Appends all elements in the specified list to the end of this list, in the order that they are returned by the * specified list's iterator. * * @param c list containing elements to be added to this list * @return {@code true} if this list changed as a result of the call * @throws NullPointerException if the
  • 3. specified list is null */ @Override public boolean addAll(CiscList extends E> c) { if(c==null){ throw new NullPointerException(); } return false; } /** * Removes the element at the specified position in this list. Shifts any subsequent elements to the left * (subtracts one from their indices). Returns the element that was removed from the list. * * @param index the index of the element to be removed * @return the element previously at the specified position * @throws IndexOutOfBoundsException if the index is out of range */ @Override public E remove(int index) { if(index<0 || index>size){ throw new IndexOutOfBoundsException(); } return null; } /** * {@link #remove} recursive helper method. Removes the node following n if it contains the element at the specified * index. * * @param index the index of the element to be removed * @param currentIndex the index of the node parameter * @param n the node containing the element at currentIndex * @return */ private E remove(int index, int currentIndex, Node n) { return null; } /** * Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not * contain the element (compared using the {@code equals} method). This implementation should stop searching as * soon as it is able to determine that the specified element is not present. * * @param o element to search for * @return the index of the first occurrence of the specified element in this list, or -1 if this list does not * contain the element * @throws NullPointerException if the specified element is null */ @Override public int indexOf(Object o) { if(o==null){ throw new NullPointerException(); } return indexOf(o,0, dummy.next); } /** * {@link #indexOf} recursive helper method. Returns currentIndex if the element contained in the node parameter is * equal to the specified element to search for. This implementation should stop searching as soon as it is able to * determine that the specified element is not present. * * @param o element to search for * @param currentIndex the index of the node parameter * @param n the node containing the element at currentIndex * @return the index of the first occurrence of the specified element in this list, or -1 if this list does not * contain the element */ private int indexOf(Object o, int currentIndex, Node n) { if(n.data.equals(o)){ return currentIndex; } else if(n==dummy){ return -1; } else if(n.data.compareTo((E)o)>0){ return -1; } else{ return indexOf(o,currentIndex+1,n.next); } } /** * Returns a string representation of this list. This string should consist of a comma separated list of values * contained in this list, in order, surrounded by square brackets (examples: [3, 6, 7] and []). * * @return a string representation of this list */ public String toString() { return null; } /** * {@link #toString} recursive helper method. Returns a string representation of this list, beginning with the * element in the specified node * * @param n the node containing the next element to append to the string * @return a string representation of this list, beginning with the element in the specified node */ private String toString(Node n) { return null; } private static class Node { private E data; private Node next; private Node(E data, Node next) { this.data = data; this.next = next; } } private class CiscLinkedListIterator implements Iterator { /** * A reference to the node containing the next element to return, or to the dummy node if there are no more * elements to return. */ private Node nextNode; /** * Constructs an iterator ready to return the first element in the list (if present). */ public CiscLinkedListIterator() { nextNode=dummy.next; } /** * Returns {@code true} if the iteration has more elements. (In other words, returns {@code true} if * {@link #next} would return an element rather than throwing an exception.) * * @return {@code true} if the iteration has more elements */ @Override public boolean hasNext() { return nextNode!=dummy && nextNode!=null; } /** * Returns the next element in the iteration. * * @return the next element in the iteration * @throws NoSuchElementException if the iteration has no more elements */ @Override public E next() {
  • 4. if(!hasNext()){ throw new NoSuchElementException(); } E data=nextNode.data; nextNode=nextNode.next; return data; } } }