From a1e33370dffd2b92ed5dc3b76df5ee999c9cecb6 Mon Sep 17 00:00:00 2001 From: 7taniya <108205147+7taniya@users.noreply.github.com> Date: Sat, 29 Oct 2022 18:18:21 +0530 Subject: [PATCH] Circular doubly linked list --- Java/circulardoublylinkedlist.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Java/circulardoublylinkedlist.java diff --git a/Java/circulardoublylinkedlist.java b/Java/circulardoublylinkedlist.java new file mode 100644 index 0000000..4daa5b3 --- /dev/null +++ b/Java/circulardoublylinkedlist.java @@ -0,0 +1,18 @@ +static void insertEnd(int value) +{ + if (start == null) { + Node new_node = new Node(); + new_node.data = value; + new_node.next = new_node.prev = new_node; + start = new_node; + return; + } + Node last = (start).prev; + Node new_node = new Node(); + new_node.data = value; + new_node.next = start; + (start).prev = new_node; + new_node.prev = last; + last.next = new_node; +} +