The document provides a Java implementation of a circular linked list with methods to add, delete, and print nodes. It demonstrates adding nodes at both the beginning and end of the list, as well as deleting the first and last nodes. The main method showcases these functionalities through console output.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
4 views5 pages
Circualr LinkedList Applications
The document provides a Java implementation of a circular linked list with methods to add, delete, and print nodes. It demonstrates adding nodes at both the beginning and end of the list, as well as deleting the first and last nodes. The main method showcases these functionalities through console output.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5
package LinkedCircularPackage;
public class App {
public static void main(String[] args) {
LLNode<Integer> circularList = null;
//How to add a new node at the begining of a circular linked list?
System.out.println("Adding a new node at the begining of a circular linked list:"); System.out.println("Add: 8"); circularList = addFirst(circularList, 8); System.out.println("Add: 3"); circularList = addFirst(circularList, 3); System.out.println("Add: 5"); circularList = addFirst(circularList, 5);
//How to print all elements in a Circular linked list?
System.out.println("Printing all elements in a Circular linked list:"); printCircularList(circularList);
//How to identify the referenced node in a circular linked list?
//How to delete the first node from a circular linked list?
System.out.println("Delete the first node from a circular linked list:"); circularList = deleteFirst(circularList); printCircularList(circularList);
// Reinitialize the circularList.
circularList = null;
//How to add a new node at the end of a circular linked list?
System.out.println("\nAdding a new node at the end of a circular linked list:"); System.out.println("Add: 8"); circularList = addLast(circularList, 8); System.out.println("Add: 3"); circularList = addLast(circularList, 3); System.out.println("Add: 5"); circularList = addLast(circularList, 5);
//How to print all elements in a Circular linked list?
System.out.println("Printing all elements in a Circular linked list:"); printCircularList(circularList);
//How to identify the referenced node in a circular linked list?