SlideShare ist ein Scribd-Unternehmen logo
1 von 4
Note: Can someone help me with the private E get(int index, int currentIndex, Node n)method.
The code is not running. Also I need help with the public void add(int index, E element) method
too. Please use the parameters provided with the code to solve. 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 null; } /** * 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) { 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();
} Node curr = dummy.next; for(int i=0;i n) { if(index<0 || index>=size){ throw new
IndexOutOfBoundsException(); } Node curr = head; for(int i=0;i next_curr=curr.next;
curr.next=n; while(n.next) { n = n.next; //finding end of n headed linked list n.next =
next_curr;//adding rest linked list at end of n headed linked list } if(index==0) { return n; } else {
return head; } } /** * * @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) { } /** * 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) { 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) { 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() { } /** * 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 false; }
/** * 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() { return null; } } }
Note- Can someone help me with the private E get(int index- int curren (1).docx

Weitere ähnliche Inhalte

Ähnlich wie Note- Can someone help me with the private E get(int index- int curren (1).docx

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
 
public class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdfpublic class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdfaccostinternational
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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 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
 
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
 
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
 
A popular implementation of List is ArrayList- Look up how to instanti.pdf
A popular implementation of List is ArrayList- Look up how to instanti.pdfA popular implementation of List is ArrayList- Look up how to instanti.pdf
A popular implementation of List is ArrayList- Look up how to instanti.pdfarsarees
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfConint29
 
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
 

Ähnlich wie Note- Can someone help me with the private E get(int index- int curren (1).docx (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
 
public class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdfpublic class MyLinkedListltE extends ComparableltEgtg.pdf
public class MyLinkedListltE extends ComparableltEgtg.pdf
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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 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
 
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
 
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
 
A popular implementation of List is ArrayList- Look up how to instanti.pdf
A popular implementation of List is ArrayList- Look up how to instanti.pdfA popular implementation of List is ArrayList- Look up how to instanti.pdf
A popular implementation of List is ArrayList- Look up how to instanti.pdf
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.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
 

Mehr von VictorzH8Bondx

A large bullfrog hops onto a prime spot on log and shoves off a turtle.docx
A large bullfrog hops onto a prime spot on log and shoves off a turtle.docxA large bullfrog hops onto a prime spot on log and shoves off a turtle.docx
A large bullfrog hops onto a prime spot on log and shoves off a turtle.docxVictorzH8Bondx
 
Passengers arrive at the taxi stand at a Poisson rate of 2 per minute.docx
Passengers arrive at the taxi stand at a Poisson rate of 2 per minute.docxPassengers arrive at the taxi stand at a Poisson rate of 2 per minute.docx
Passengers arrive at the taxi stand at a Poisson rate of 2 per minute.docxVictorzH8Bondx
 
Pattern recognition is one of the core tasks in data mining- Direction.docx
Pattern recognition is one of the core tasks in data mining- Direction.docxPattern recognition is one of the core tasks in data mining- Direction.docx
Pattern recognition is one of the core tasks in data mining- Direction.docxVictorzH8Bondx
 
Pathogenesis of yersinia bacteria- And Virulence factors of yersinia.docx
Pathogenesis of yersinia bacteria- And  Virulence factors of yersinia.docxPathogenesis of yersinia bacteria- And  Virulence factors of yersinia.docx
Pathogenesis of yersinia bacteria- And Virulence factors of yersinia.docxVictorzH8Bondx
 
Pareto Efficiency- clearly provide the following- (1) establish the re.docx
Pareto Efficiency- clearly provide the following- (1) establish the re.docxPareto Efficiency- clearly provide the following- (1) establish the re.docx
Pareto Efficiency- clearly provide the following- (1) establish the re.docxVictorzH8Bondx
 
Part - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docx
Part  - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docxPart  - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docx
Part - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docxVictorzH8Bondx
 
P90- lbps (Type an integer or a decimal- Do not round-).docx
P90- lbps (Type an integer or a decimal- Do not round-).docxP90- lbps (Type an integer or a decimal- Do not round-).docx
P90- lbps (Type an integer or a decimal- Do not round-).docxVictorzH8Bondx
 
p2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docx
p2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docxp2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docx
p2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docxVictorzH8Bondx
 
P(X-17)-n-20-p-0-9.docx
P(X-17)-n-20-p-0-9.docxP(X-17)-n-20-p-0-9.docx
P(X-17)-n-20-p-0-9.docxVictorzH8Bondx
 
P(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docx
P(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docxP(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docx
P(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docxVictorzH8Bondx
 
Over the past few decades of warming- most biological organisms have a.docx
Over the past few decades of warming- most biological organisms have a.docxOver the past few decades of warming- most biological organisms have a.docx
Over the past few decades of warming- most biological organisms have a.docxVictorzH8Bondx
 
OVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docx
OVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docxOVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docx
OVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docxVictorzH8Bondx
 
Out of Trait- behavioural- relational and contingency approaches of le.docx
Out of Trait- behavioural- relational and contingency approaches of le.docxOut of Trait- behavioural- relational and contingency approaches of le.docx
Out of Trait- behavioural- relational and contingency approaches of le.docxVictorzH8Bondx
 
Output of electron transport chain (2-2).docx
Output of electron transport chain (2-2).docxOutput of electron transport chain (2-2).docx
Output of electron transport chain (2-2).docxVictorzH8Bondx
 
Overview Dagnostic coding and reporting guidelines for outpatient serv.docx
Overview Dagnostic coding and reporting guidelines for outpatient serv.docxOverview Dagnostic coding and reporting guidelines for outpatient serv.docx
Overview Dagnostic coding and reporting guidelines for outpatient serv.docxVictorzH8Bondx
 
out of Stanford University and founded the blood testing company clini.docx
out of Stanford University and founded the blood testing company clini.docxout of Stanford University and founded the blood testing company clini.docx
out of Stanford University and founded the blood testing company clini.docxVictorzH8Bondx
 
Otosclerosis (abnormal bone growth) of the stapes would cause what kin.docx
Otosclerosis (abnormal bone growth) of the stapes would cause what kin.docxOtosclerosis (abnormal bone growth) of the stapes would cause what kin.docx
Otosclerosis (abnormal bone growth) of the stapes would cause what kin.docxVictorzH8Bondx
 
Oriole Corporation has outstanding 19-000 shares of $5 par value commo.docx
Oriole Corporation has outstanding 19-000 shares of $5 par value commo.docxOriole Corporation has outstanding 19-000 shares of $5 par value commo.docx
Oriole Corporation has outstanding 19-000 shares of $5 par value commo.docxVictorzH8Bondx
 
Oriole Marine Products began the year with 10 units of marine floats a.docx
Oriole Marine Products began the year with 10 units of marine floats a.docxOriole Marine Products began the year with 10 units of marine floats a.docx
Oriole Marine Products began the year with 10 units of marine floats a.docxVictorzH8Bondx
 
Organizations use corporate strategy to select target domains- O.docx
Organizations use corporate strategy to select target domains-      O.docxOrganizations use corporate strategy to select target domains-      O.docx
Organizations use corporate strategy to select target domains- O.docxVictorzH8Bondx
 

Mehr von VictorzH8Bondx (20)

A large bullfrog hops onto a prime spot on log and shoves off a turtle.docx
A large bullfrog hops onto a prime spot on log and shoves off a turtle.docxA large bullfrog hops onto a prime spot on log and shoves off a turtle.docx
A large bullfrog hops onto a prime spot on log and shoves off a turtle.docx
 
Passengers arrive at the taxi stand at a Poisson rate of 2 per minute.docx
Passengers arrive at the taxi stand at a Poisson rate of 2 per minute.docxPassengers arrive at the taxi stand at a Poisson rate of 2 per minute.docx
Passengers arrive at the taxi stand at a Poisson rate of 2 per minute.docx
 
Pattern recognition is one of the core tasks in data mining- Direction.docx
Pattern recognition is one of the core tasks in data mining- Direction.docxPattern recognition is one of the core tasks in data mining- Direction.docx
Pattern recognition is one of the core tasks in data mining- Direction.docx
 
Pathogenesis of yersinia bacteria- And Virulence factors of yersinia.docx
Pathogenesis of yersinia bacteria- And  Virulence factors of yersinia.docxPathogenesis of yersinia bacteria- And  Virulence factors of yersinia.docx
Pathogenesis of yersinia bacteria- And Virulence factors of yersinia.docx
 
Pareto Efficiency- clearly provide the following- (1) establish the re.docx
Pareto Efficiency- clearly provide the following- (1) establish the re.docxPareto Efficiency- clearly provide the following- (1) establish the re.docx
Pareto Efficiency- clearly provide the following- (1) establish the re.docx
 
Part - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docx
Part  - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docxPart  - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docx
Part - Pleace indinate hnu ie the trancartinn afferte the arcnuntinn.docx
 
P90- lbps (Type an integer or a decimal- Do not round-).docx
P90- lbps (Type an integer or a decimal- Do not round-).docxP90- lbps (Type an integer or a decimal- Do not round-).docx
P90- lbps (Type an integer or a decimal- Do not round-).docx
 
p2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docx
p2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docxp2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docx
p2+2pq+q2-1Q4- In a population that is in Hardy-Weinberg equilibrium-.docx
 
P(X-17)-n-20-p-0-9.docx
P(X-17)-n-20-p-0-9.docxP(X-17)-n-20-p-0-9.docx
P(X-17)-n-20-p-0-9.docx
 
P(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docx
P(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docxP(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docx
P(A)-0-5-P(B)-0-6-P(AB)-0-4- Find P(A union B) a- 0-7 b- 0-6 c- 0-86 d.docx
 
Over the past few decades of warming- most biological organisms have a.docx
Over the past few decades of warming- most biological organisms have a.docxOver the past few decades of warming- most biological organisms have a.docx
Over the past few decades of warming- most biological organisms have a.docx
 
OVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docx
OVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docxOVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docx
OVERVIEW- In 2001- Troy Stubblefield- the owner of Shreveport Air Tool.docx
 
Out of Trait- behavioural- relational and contingency approaches of le.docx
Out of Trait- behavioural- relational and contingency approaches of le.docxOut of Trait- behavioural- relational and contingency approaches of le.docx
Out of Trait- behavioural- relational and contingency approaches of le.docx
 
Output of electron transport chain (2-2).docx
Output of electron transport chain (2-2).docxOutput of electron transport chain (2-2).docx
Output of electron transport chain (2-2).docx
 
Overview Dagnostic coding and reporting guidelines for outpatient serv.docx
Overview Dagnostic coding and reporting guidelines for outpatient serv.docxOverview Dagnostic coding and reporting guidelines for outpatient serv.docx
Overview Dagnostic coding and reporting guidelines for outpatient serv.docx
 
out of Stanford University and founded the blood testing company clini.docx
out of Stanford University and founded the blood testing company clini.docxout of Stanford University and founded the blood testing company clini.docx
out of Stanford University and founded the blood testing company clini.docx
 
Otosclerosis (abnormal bone growth) of the stapes would cause what kin.docx
Otosclerosis (abnormal bone growth) of the stapes would cause what kin.docxOtosclerosis (abnormal bone growth) of the stapes would cause what kin.docx
Otosclerosis (abnormal bone growth) of the stapes would cause what kin.docx
 
Oriole Corporation has outstanding 19-000 shares of $5 par value commo.docx
Oriole Corporation has outstanding 19-000 shares of $5 par value commo.docxOriole Corporation has outstanding 19-000 shares of $5 par value commo.docx
Oriole Corporation has outstanding 19-000 shares of $5 par value commo.docx
 
Oriole Marine Products began the year with 10 units of marine floats a.docx
Oriole Marine Products began the year with 10 units of marine floats a.docxOriole Marine Products began the year with 10 units of marine floats a.docx
Oriole Marine Products began the year with 10 units of marine floats a.docx
 
Organizations use corporate strategy to select target domains- O.docx
Organizations use corporate strategy to select target domains-      O.docxOrganizations use corporate strategy to select target domains-      O.docx
Organizations use corporate strategy to select target domains- O.docx
 

Kürzlich hochgeladen

Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 

Kürzlich hochgeladen (20)

Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 

Note- Can someone help me with the private E get(int index- int curren (1).docx

  • 1. Note: Can someone help me with the private E get(int index, int currentIndex, Node n)method. The code is not running. Also I need help with the public void add(int index, E element) method too. Please use the parameters provided with the code to solve. 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 null; } /** * 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
  • 2. boolean add(E 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(); } Node curr = dummy.next; for(int i=0;i n) { if(index<0 || index>=size){ throw new IndexOutOfBoundsException(); } Node curr = head; for(int i=0;i next_curr=curr.next; curr.next=n; while(n.next) { n = n.next; //finding end of n headed linked list n.next = next_curr;//adding rest linked list at end of n headed linked list } if(index==0) { return n; } else { return head; } } /** * * @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) { } /** * 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) { 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) { return null; } /** * {@link #remove} recursive helper method. Removes the node
  • 3. 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() { } /** * 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 false; } /** * 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() { return null; } } }