Data Structures:

At first i considered that the data structures are very hard to learn.After that i found the youtube channel named “Apna college” handling by the shradha khapra.Today I learnt the linked list in the both from the scratch and the using of the collection frameworks.I am using the java language which is very easy to solve the problems by using the classes and the objects.
Here is the linked list code using the scratch:
import java.util.*;
public class Main{
static class Node{
String data;
Node next;
Node(String data){
this.data = data;
this.next = null;
}
}
public static void main(String[]args){ Scanner sc = new Scanner(System.in); String a = sc.nextLine();
String b = sc.nextLine();
String c = sc.nextLine();
String d = sc.nextLine();
//creating the nodes :
Node first = new Node(a);
Node second = new Node(b);
Node third = new Node(c);
Node four = new Node(d);
//linking the nodes together:
first.next = second;
second.next = third;
third.next = four;
//printing the linked list:
Node currNode = first;
while(currNode!=null){
System.out.print(currNode.data+"->");
currNode = currNode.next;
}
System.out.println("Null");
}
}
ALSO LINKED LIST BY USING THE COLLECTION FRAME WORKS:
import java.util.*;
public class Main{
public static void main(String[]args){
LinkedList<Integer>list = new LinkedList<Integer>();
list.add(0);
list.add(1);
list.add(2);
list.add(5);
System.out.println(list);
}
}
// THE OUT PUT IS IN THE FORM OF [0,1,2,5]
Subscribe to my newsletter
Read articles from divij buddareddy directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

divij buddareddy
divij buddareddy
I am b-tech undergraduate in the kalasalingam academy of the research and eduation which is located in the small village krishnankovil,Tamilnadu.