1463 1/29/2017 12:00:53 AM

class LinkedList
    Node head;  // head of list
    /* Linked list Node*/
    class Node
        int data;
        Node next;
        // Constructor to create a new node
        // Next is by default initialized as null
        Node(int d) {data = d;}

A linked list is represented by a pointer to the first node of the linked list.

The first node is called a head. If the linked list is empty, then the value of head is NULL.

Each node in a list consists of at least two parts:

  1. Data
  2. Pointer to the next node