You can refer for Linked List in Java program here: link
This is a program to reverse a linked list using recursion.
public String reverseList() {
return reverseList(this, new StringBuffer()).toString();
}
private StringBuffer reverseList(LinkedList L, StringBuffer sb) {
if(L!=null) {
reverseList(L.next, sb);
sb.append(L.data).append(", ");
}
return sb;
}
No comments:
Post a Comment