Untitled

Run Settings
LanguageJava
Language Version
Run Command
class Node{ int data; Node next; Node prev; Node(int data) { this.data=data; next = null; } } class Linkedlist{ Node head; Node tail; void insert_atFront( int new_data){ Node new_node = new Node(new_data); new_node.data = new_data; new_node.next = head; head = new_node; } void printList(){ int count = 0; Node node = head; while(node!=null){ System.out.println(node.data); node = node.next; count++; } } void insert(int c, int datas){ Node noder = new Node(datas); Node before = traverseindex(c-1); Node after = traverseindex(c); before.next = noder; noder.next = after; } void remove(int rpos){ Node beforeremove = traverseindex(rpos-1); Node afterremove = traverseindex(rpos+1); beforeremove.next = afterremove; } void insert_atlast(int data){ Node last_node = new Node(data); Node node = head; while(node.next!=null){ node = node.next; } node.next = last_node; last_node.next = null; } Node traverseindex( int t) { int counter =0; Node node = head; while(counter<t) { node = node.next; counter++; } return node; } public static void main(String[] args){ Linkedlist list = new Linkedlist(); list.insert_atFront(8); list.insert_atFront(9); list.insert_atFront(10); list.printList(); list.insert(2,55); //list.printList(); list.insert_atlast(75); list.printList(); }}
Editor Settings
Theme
Key bindings
Full width
Lines