CircularDoublyLinkedList - class Node String value Node next Node prev public Node next = null prev = null public Node(String val Node n Node p value =

CircularDoublyLinkedList - class Node String value Node...

This preview shows page 1 - 3 out of 5 pages.

class Node{String value;Node next; Node prev;public Node(){next = null;prev = null;}public Node(String val, Node n, Node p){value = val;next = n;prev = p;}public void setNext(Node n){next = n;}public void setPrev(Node p){prev = p;} public Node getNext(){return next;}public Node getPrev(){return prev;}public void setData(String val){value = val;}public String getData(){return value;}}class linkedList{private Node first;private Node last;public int size;public linkedList(){first = null;last = null;size = 0;
Background image
}public boolean isEmpty(){return first == null;}public int getSize(){return size;}public void insertAtStart(String e){Node p = new Node(e, null, null); if (isEmpty()){ p.setNext(p);p.setPrev(p);first = p;last = first; }else{p.setPrev(last);last.setNext(p);first.setPrev(p);p.setNext(first);first = p; }size++ ;}public void insertAtEnd(String e){Node p = new Node(e, null, null); if (isEmpty()){p.setNext(p);p.setPrev(p);first = p;last = first;}else{p.setPrev(last);last.setNext(p);first.setPrev(p);p.setNext(first);last = p; }size++;}public void insertAtPos(String e, int index){Node p = new Node(e, null, null);
Background image
Image of page 3

You've reached the end of your free preview.

Want to read all 5 pages?

  • Spring '14
  • Return statement, Void type

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture