Flat Preloader Icon

Singly Linked List

Overview

  1. what is a list?
  2. what is a node
  3. Singly linked lis
  4. SLL ADT
  5. Array vs Dynamic Array vs SLL

What Is A List ?

  1. List is a linear collection of data items also known as List item

Example 1:

  • Marks of tests | List of marks  ( list item:int)

            20 15 21 24 18 23 25….

Example 2:

  • List Of Guests ( list item:string)

            “Singh”,”chaturvedi”,”Dubey”,”khan”…..

Example 3:

  • List Of Students ( list item:student)

               Rahul    |    Savita       | dilip

                 17        |       19        |     18

       xyz@x.com | xy@x.com | x@x.com………

Singly Linked List

  • A singly linked list is a type of linked list where each node in the list points to the next node in the sequence. The last node points to null, indicating the end of the list. Singly linked lists are relatively simple and can be implemented efficiently. However, they do not support backward traversal.
  • Here is a simple implementation of a singly linked list in Java:

What Is A Node ?

Example 1:

  • Marks of tests | List of marks  ( int item;)(node next;)

            20 15 21 24 18 23 25….

node start = new node();

 

Singly Linked List

Insertion:

  • starting
  • Last
  • after a node

deletion:

  • first note
  • Last node
  • Specific node

Array vs Dynamic Array vs SLL

Array:

  • fixed Size

Dynamic Array:

  • growable
  • Shrinkable

SLL:

  • Dynamic 
  • growable
  • Shrinkable