Concept;Double-Ended LinkList- it is a first and last reference. It can be thearrangement of such qualities in every inputs that are available. (wiki,google)
Programer: Niel Jay F. Ehilla
Subject: Data Structure
Purpose: To know about Double-Ended LinkList
Code/Implementation;public class Link{
private int idata;
private long ddata;
link next;
public Link (int nidata, long nddata){
iData=nidata;
dData=nddata;
}
}
public class FirstLastLink{
private LinkFirst;
private LinkLast;
public FirstLastLink(){
first=null;
last=null;
}
public boolean isEmpty(){
return(first&&last==null);
}
public void insertFirst(int nidata, long nddata){
Link newLink=new Link(nidata, nddata);
new.next=first;
first=newLink;
}
public void insertLast(int nidata, long nddata){
Link newLink=new Link(nidata,nddata);
newLink.next=last;
last=newLink;
}
public Link deleteFirst(int nidata, long nddata){
Link temp=first;
first=first.next;
return temp;
}
public Link deleteLast(int nidata, long nidata){
Link temp2=last;
last=last.next;
return temp2;
}
public void displaylist(){
System.out.print("The List(first--->last):");
Link current=first;
while(current!=null){
current.displaylink();
current=current.next;
}
Link current2=last;
while(current2!=null){
current2.displaylink();
current2=current2.next;
}
System.out.println(" ");
}
}
public class Apps{
public static void main(String[]args){
FirstLastList theList=new FirstLastList();
theList.insertFirst(001, 1,000,000);
theList.insertFirst(002, 2,000,000);
theList.insertFirst(003, 3,000,000);
theList.insertLast(09, 4,000);
theList.insertLast(25, 5,000);
theList.insertLast(28, 6,000);
System.out.println(theList);
theList.deleteFirst();
theList.deleteLast();
System.out.println(theList);
}
}
Reference;http://www.google.com.ph/search?hl=en&q=doubly+link+list&meta=