Posts

Showing posts with the label single linkedList

Single Linked List in Java (Java)

Image
Singly Linked Lists are a type of data structure. It is a type of list. In a singly linked list each node in the list stores the contents of the node and a pointer or reference to the next node in the list. It does not store any pointer or reference to the previous node. It is called a singly linked list because each node only has a single link to another node. To store a single linked list, you only need to store a reference or pointer to the first node in that list. The last node has a pointer to nothingness to indicate that it is the last node. Source code import java.util.*; public class LinkedList<AnyType> implements Iterable<AnyType> {    private Node<AnyType> head;  /**    *  Constructs an empty list    */    public LinkedList()    {       head = null;    }  /**    *  Returns true if the list is empty    * ...