Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
LinkedList updLL1=new LinkedList();
updLL1.formRes(LL1,LL2,LL3,MID);
updLL1.display();
updLL1.Size();
updLL1.size();

*/



import java.util.*;
import java.lang.*;
import java.io.*;
class LinkedList {

public class LinkedList {

private class Node{
int data;
Node next;
Expand All @@ -52,9 +52,16 @@ private class Node{
this.next = null;
}
}
public Node head = null;
public Node tail = null;
private int size=0;

private Node head;
private Node tail;
private int size;

public LinkedList() {
head = null;
tail = null;
size = 0;
}

public void addLast(int data) {
Node newNode = new Node(data);
Expand Down Expand Up @@ -92,6 +99,7 @@ public void formLL2(LinkedList LL1) {
current=current.next.next;
}
}

public void formLL3(LinkedList LL1) {
Node current=LL1.head.next;
while(current.next!=null&&current.next.next!=null) {
Expand All @@ -100,6 +108,7 @@ public void formLL3(LinkedList LL1) {
current=current.next.next;
}
}

public Node mid() {
Node slow=this.head;
Node fast=this.head;
Expand All @@ -109,11 +118,13 @@ public Node mid() {
}
return slow;
}

public Node midValue() {
int sum=this.head.data+this.tail.data;
Node mid=new Node(sum);
return mid;
}

public void formRes(LinkedList LL1,LinkedList LL2,LinkedList LL3,Node MID) {
Node LL1mid=LL1.mid();
Node currentLL1=LL1.head;
Expand All @@ -135,7 +146,8 @@ else if(currentLL2==null&&currentLL3!=null) {
currentLL1=currentLL1.next;
}
}
public void Size() {

public void size() {
System.out.println(this.size);
}
}