The document discusses linked lists, which are a linear data structure composed of nodes that contain data and a link to the next node. Linked lists allow for easy insertion and removal of nodes, unlike arrays which have fixed sizes. There are several types of linked lists including single linked lists, double linked lists, circular linked lists, and circular double linked lists. Common operations on linked lists include creation, insertion, deletion, traversal, searching, concatenation, and displaying the list.
2. INTRODUCTION
• Data structure :- A data structure is a logical representation of data and operation that can be
perform on the data.
There are two types of Data Structure :
1. Primitive Data Structure.
2. Non-Primitive Data Structure.
• 1. Primitive Data Structure :- Data which can directly operate by machine is known as
primitive data structure.
• These are the examples of primitive data structure Integer, Pointer, Char, Boolean etc.
3. • 2. Non-Primitive Data Structure :- Data which can not directly operate by machine but
need some algorithm to perform it’s task is known as non-primitive data structure.
• There are two types Non-Primitive Data Structure :
1. Linear Data Structure.
2. Non-Linear Data Structure.
Linear Data Structure :- Linear data structure is in which all the data are arranged in
sequence.
These are the examples of Linear data structure Array, Stack, Queue, Linked List.
• Linked List :- Linked List is a linear data structure. It contains nodes. Each node contains two
parts, DATA part and LINK part.
DATA contains elements and
LINK contains address of another node.
4. LIMITATIONS OF ARRAYS
Arrays are simple to understand and elements of an array are easily accessible but have some
limitations.
Array have a fixed dimension.
Once the size of an array is decided it can not be change during execution.
Array elements always stored in continues memory locations.
Operations like insertion or deletion of the array elements are quite difficult.
To overcome this limitations we use Linked List.
5. LINKED LIST
• Linked list is a collection of elements called nodes.
• Each node contains two parts. They are DATA part and LINK part.
• The principal benefit of a linked list over a conventional array is that the list elements can easily
be inserted or removed without reallocation or reorganization of the entire structure because the
data items need not be stored contiguously in memory or on disk, while an array has to be
declared in the source code, before compiling and running the program.
• Linked lists allow insertion and removal of nodes at any point in the list.
NODE
Data Link
6. 1000 2000 3000
[ LINKED LIST ]
• The above figure shows the example of marks obtained by different students can be stored in a
linked list.
• NULL indicates the end of the list.
25 2000 29 NULL26 3000
7. ADVANTAGES
• Linked lists are a dynamic data structure, allocating the needed memory while the program is
running.
• Insertion and deletion node operations are easily implemented in a linked list.
• Linear data structures such as stacks and queues are easily executed with a linked list.
• They can reduce access time and may expand in real time without memory overhead.
8. DISADVANTAGES
• They have a quite difficult to use more memory due to pointers requiring extra storage space.
• Nodes in a linked list must be read in order from the beginning as linked lists are
inherently sequential access.
• Nodes are stored in continuously, greatly increasing the time required to access individual
elements within the list.
• Difficulties arise in linked lists when it comes to reverse traversing. For instance, singly linked
lists are cumbersome to navigate backwards and while doubly linked lists are somewhat easier to
read, memory is wasted in allocating space for a back pointer.
9. OPERATIONS ON LINKED LIST
• The basic operations on linked list are :-
1. Creation
2. Insertion
3. Deletion
4. Traversing
5. Searching
6. Concatenation
7. Display
10. Creation :- Creation operation is used to create a new linked list.
Insertion :- Insertion operation is used to insert a new node in the linked list. A new node can
be inserted at the beginning of a linked list or at the end of linked list or at the specified position
of a linked list. If the list is empty, then the new node is inserted as a first node.
Deletion :- Deletion operation is used to delete a node from the linked list. It can be deleted
from the beginning of a linked list or from the end of linked list or from the specified position of
a linked list.
Traversing :- Traversing operation is a process of going through all the nodes of a linked list
from one end to the another end. If we start traversing from the very first node towards the last
node, it is called forward traversing. If we start traversing from the last node towards the first
node, it is called backward traversing.
11. Searching :- Searching operation is a process of accessing the desired node in the list. We start
searching node - by - node and compare the data of the node with the key.
Concatenation :- Concatenation operation is the process of appending the second list to the end
of the first list. When we concatenate two list, the resultant list become larger size.
Display :- Display operation is used to print each and every node’s information.
12. TYPES OF LINKED LIST
I. Single linked list.
II. Double linked list.
III. Circular linked list.
IV. Circular double linked list.
13. SINGLE LINKED LIST :-
• A single linked list is one in which all nodes are linked together in some sequential
manner.
• There is only one way traversal which is forward traversal.
• It is made of two parts Data and Link.
Data contains the element.
Link contains the address of next node.
• Last node link part contains null value which represents the end of the list. As shown in
below figure :
[ SINGLE LINKED LIST ]
Data Link Data NULLData Link
14. DOUBLE LINKED LIST :-
• A double linked list is one in which all nodes are linked together in some sequential
manner.
• There is two way traversal which are forward and backward traversals.
• It is made of three parts one Data and two Link.
Data contains the element.
First Link contains the address of previous node.
Second Link contains the address of next node.
• First node link and Last node link part contains null value which represents the end of
the list. As shown in below figure :
[ DOUBLE LINKED LIST ]
Prev
Link
DATA
NEXT
LINK
NULL DATA
NEXT
LINK
Prev
Link
DATA NULL
15. CIRCULAR LINKED LIST :-
• A circular linked list is one in which all nodes are linked together in some sequential
manner.
• There is only one way traversal in circular manner which is forward traversal.
• It is made of two parts Data and Link.
Data contains the element.
Link contains the address of next node.
• Last node link part contains the address of first node. As shown in below figure :
[ CIRCULAR LINKED LIST ]
Data Link Data LinkData Link
16. CIRCULAR DOUBLE LINKED LIST :-
• A circular double linked list is one in which all nodes are linked together in some sequential
manner.
• There is two way traversal in circular manner which are forward and backward traversals.
• It is made of three parts one Data and two Link.
Data contains the element.
First Link contains the address of previous node.
Second Link contains the address of next node.
• First node PREV link part contains the address of last node and Last node NEXT link part
contains the address of first node. As shown in below figure :
[ CIRCULAR DOUBLE LINKED LIST ]
Prev
Link
DATA
NEXT
LINK
PREV
LINK
DATA
NEXT
LINK
Prev
Link
DATA
NEXT
LINK