public class LinkList
{
private Node list;
private int count; // number of values stored in the list
public LinkList(){
list = null;
count = 0;
}
// Returns number of values in the LinkList
public int count() {
return count;
}
/*
* delete all nodes with this value
* if the count is zero do nothing
* if count is 1 delete front node (can use front() and ignore return)
* else travel the list and when found make prev.next cur.next ... return
* if still in method delete rear node.
*
*/
public void deleteNode(int value)
{
}
}
public class Node{
int value;
Node next;
public Node() {
next=null;
}
public Node(int n, Node nextNode){
setValue(n);
setNext(nextNode);
}
public int getValue(){
return value;
}
public void setValue(int n){
value = n;
}
public Node getNext(){
return next;
}
public void setNext(Node node){
next = node;
}
public boolean equals(Node other) {
return (this.getValue() == other.getValue());
}
public String toString() {
return "" + value;
}
}
質問する
7104 次
3 に答える
1
+------+ +------+ +------+
| | | | | |
Step 0 | |+------>| |+------>| |
| | | | | |
| | | | | |
+------+ +------+ +------+
+----------------+
+------+ | +------+ | +------+
| |+--+ | | +-->| |
Step 1 | | | |+------>| |
| | | | | |
| | | | | |
+------+ +------+ +------+
+------+ +------+
| | | |
Step 2 | |+---------------------->| |
| | | |
| | | |
+------+ +------+
于 2013-06-26T22:49:57.117 に答える