第一次在CDSN上提问,不知道有没有大神可以帮我看看:
这是我们这个星期的作业要求:
The Sorted List ADT
Implement the SortedList class. The SortedList class extends
the List class. Both can be seen here. Your assignment is to
implement (recursively) all of the abstract methods of the List class.
They are:
insert (recursive)
iterator
remove (recursive)
retrieve (recursive)
search (recursive)
You must also implement an Iterator inner class for the
SortedList class. You must submit a modified SortedList.java
file with your source code. Do not submit and do not modify
the List.java file.
然后我试着写了把retrieve,search和iterator方法都写出来了,唯有insert和remove(我想这两个应该差不多)写不出来,这是我试的代码,被报错,求大神们指点
public void insert(E data){
insert(head, data);
private insert(Node curr, data){
Node temp = new Node (data);
if (curr==null || data.compareTo(curr.data)<0){
temp.next=curr;
curr=temp;
break;
}
else{
continue;
}
return insert(curr.next, data);
}
return;
}