Skip to content

Instantly share code, notes, and snippets.

@LucioFranco
Created March 28, 2015 02:30
Show Gist options
  • Save LucioFranco/df15de6b3f4b6d42dfe6 to your computer and use it in GitHub Desktop.
Save LucioFranco/df15de6b3f4b6d42dfe6 to your computer and use it in GitHub Desktop.
public LinkedList iCopy() {
LinkedList temp = new LinkedList();
Node currentNode = this.startNode;
while(currentNode != null) {
temp.add(currentNode.getValue());
currentNode = currentNode.getNextNode();
}
return temp;
}
public LinkedList rCopy(LinkedList list, Node node) {
if(list == null) {
list = new LinkedList();
node = this.startNode;
}
if(node == null) {
return list;
}else {
list.add(node.getValue());
rCopy(list, node.getNextNode());
}
return list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment