diff --git a/Reverse linklist using resursion.java b/Reverse linklist using resursion.java new file mode 100644 index 0000000000..348eaf7229 --- /dev/null +++ b/Reverse linklist using resursion.java @@ -0,0 +1,20 @@ +public class ReverseLinkedList { +public static void main(String[] args) { + LinkedList li=new LinkedList(); + li.InsertData(5); + li.InsertData(55); + li.InsertData(555); + li.InsertData(5555); + Node head=li.head; + reverse(head); +} +public static void reverse(Node head) +{ + if(head==null) + return; + + reverse(head.next); + System.out.println(head.val); + +} +}