Programming Books

Linked List Concepts PDF

Written by TechPro Free

Learn Introduction to Linked List concept Step By Step with examples.Types of Linked List.Array VS Linked List. Singly Linked list. Doubly Linked List.How to insert in Linked list.

What Is Linked List

A linked list is a linear data structure. Nodes make up linked lists. Nodes are structures made up of data and a pointer to another node.  Usually the pointer is called next.

Simple Linked List Class

  • We use two classes: Node and List
  • Declare Node class for the nodes
  • data: double-type data in this example
  • next: a pointer to the next node in the list
    class Node {

    public:

    double  data;  // data

    Node*  next;  // pointer to next

    };

Types of Linked List

There are two basic types of linked list

  • Singly Linked list
  • Doubly linked list

Single Linked List

each node has only one link part Each link part contains the address of the next node in the list Link part of the last node contains NULL value which signifies the end of the node

Doubly Linked List

Doubly linked list is a linked data structure that consists of a set of sequentially linked records called nodes.  Each node contains three fields one is data part which contain data only.two other field is links part that are point or references to the previous or to the next node in the sequence of nodes.  The beginning and ending nodes’ previous and next links, respectively, point to some kind of terminator, typically a sentinel node or null to facilitate traversal of the list.

Schematic representation

 

 

Difference Array and Linked List

Array

Linked List

Fixed size  Dynamic size
Insertions and Deletions are inefficient: Elements are usually shifted. Insertions and Deletions are efficient: No shifting.
Random access i.e., efficient indexing No random access  Not suitable for operations requiring accessing elements by index such as sorting
 No memory waste if the array is full or almost full; otherwise may result in much memory waste Since memory is allocated dynamically(acc. to our need) there is no waste of memory
Sequential access is faster [Reason: Elements in contiguous memory locations] Sequential access is slow [Reason: Elements not in contiguous memory locations]

 




About the author

TechPro Free

Techprofree.com is Platform which offers Free download latest project source code in java, android, php, html, c# .net, c/c++, iphone, vb, python, jsp, asp .net, all programming lanugage.

Leave a Comment