DoublyLinkedList

What is Doubly LinkedList?

 
In Doubly LinkedList, each node consist of two references. One reference to previous Node and other to Next Node.
 
You can traverse back in Doubly LinkedList whereas you can’t traverse back in Singly LinkedList.
 

 
A simple DoublyLinkedList Class
 



package com.diaryreaders.datastructures.LinkedList;
public class DoublyLinkedList {
private DoublyLinkedList prev;
private DoublyLinkedList next;
private int data;
public DoublyLinkedList getPrev() {
return prev;
}
public void setPrev(DoublyLinkedList prev) {
this.prev = prev;
}
public DoublyLinkedList getNext() {
return next;
}
public void setNext(DoublyLinkedList next) {
this.next = next;
}
public int getData() {
return data;
}
public void setData(int data) {
this.data = data;
}
}


 

No Comments Yet

Leave a Reply

Your email address will not be published.

Lorem ipsum dolor sit amet, consectetur a dipiscing elit. Vivamus leo ante,

FOLLOW US ON