answersLogoWhite

0

Doubly circular linked list java codes?

Updated: 8/18/2019
User Avatar

Wiki User

11y ago

Best Answer

class Node

{

public Node next;

public Node previous;

public int item;

public Node(int item)

{

this.item = item;

}

public Node(int item, Node previous)

{

this.item = item;

this.previous = previous;

}

}

public class DoublyLinkList {

public static void main(String[] args) {

// TODO Auto-generated method stub

DoublyLinkList doublyLinkList = new DoublyLinkList();

Node head = doublyLinkList.addNodeFIFO(null, 1);

head = doublyLinkList.addNodeFIFO(head, 2);

head = doublyLinkList.addNodeFIFO(head, 3);

head = doublyLinkList.addNodeFIFO(head, 4);

head = doublyLinkList.addNodeFIFO(head, 5);

doublyLinkList.printdoublyLinkList(head);

Node current = head;

current = doublyLinkList.movePrevious(current);

current = doublyLinkList.moveNext(current);

current = doublyLinkList.movePrevious(current);

current = doublyLinkList.moveNext(current);

current = doublyLinkList.moveNext(current);

current = doublyLinkList.moveNext(current);

current = doublyLinkList.moveNext(current);

current = doublyLinkList.moveNext(current);

current = doublyLinkList.moveNext(current);

current = doublyLinkList.moveFirst(current);

current = doublyLinkList.moveLast(current);

// head = doublyLinkList.deleteNodeFIFO(head, 3);

//

// doublyLinkList.printdoublyLinkList(head);

//

// head = doublyLinkList.deleteNodeFIFO(head, 1);

//

// doublyLinkList.printdoublyLinkList(head);

//

// head = doublyLinkList.deleteNodeFIFO(head, 5);

//

// doublyLinkList.printdoublyLinkList(head);

}

public Node addNodeFIFO(Node head, int item)

{

System.out.println("In Add Node");

if(head item)

{

cNode.next = nNode.next;

break;

}

else

{

cNode = nNode;

nNode = nNode.next;

}

}

return head;

}

public void printdoublyLinkList(Node head)

{

while(head != null)

{

System.out.println(head.item);

head = head.next;

}

}

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Doubly circular linked list java codes?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How can implement round robin sceduler in java using circular doubly linked list?

I'm sorry brother


How do you write a Java program to implement weighted queue using circular doubly linked list?

Add weights to the elements of the queue and use an algorithm to sort the queue every time an element is added.


What is mean linked list in java?

A LinkedList is an implementation of the List interface. It is a collection that is ordered by index position, and the elements are doubly-linked to one another. The linking allows for addition and removal of elements from beginning or end. This class, as of Java 5, also implements the java.util.Queue interface.


Circular linked list in java Sample?

Basically, A linked list that has its tail linked to its head, usually the tail is kept track of since it provides constant access to both the end and the front of the linked list. ListNode x = new ListNode( value, null); //a ListNode with no next x.setNext( new ListNode( value, null)); // make its next another ListNode with no next x.getNext().setNext(x); // set the new node's next to my old node, now you have a circular linked list.


How do you import others codes in java?

using servlets, php, and database we can connect import codes into java


What are the basic types of link list in java?

linear circular double linked linear double linked circular Knowing the names does not help much when your teacher will require you to actually know what the names mean. Start reading. Programming requires lots of reading.


What are good Java script codes?

depending on the intention of the javascript codes you wish to write. there is much you can do with javascript but the only way to find out what "good Java script codes" are is to explore what you want the Javascript to do on the page.


Which programming language generates byte codes?

Java


Codes in making a receipt using a java?

yes


Is java is a platform independent language?

Yes. Apart from lower grade mobiles which have no support for java, java written codes can execute on all platforms and all devices.


Is there somebody help me to find a sites or source codes that will count the running time complexity of a certain codes in Java?

Google


Can you give the codes of the flag of Philippines using java applet?

System.out.println("No.");