Linked List in Data Structures 1
Linked List in Data Structures 1
LECTURE NOTES
MODULE- III
LINKED LIST
[INTRODUCTION]
2
Before we Start….. ASET
• Email: [email protected]
X Batch_Lab: v5t3ftw
Y Batch_Lab: tugcd3b
Theory_Lectures: dogxhmu
3
Course Content
Module 1: Introduction to Data Structures
Module 4: Trees
Learning Objectives
Definition
Representation
7
Data Structure : Linked List
Linked List
• A linked list is a linear data structure, in which the elements are NOT stored at
contiguous memory locations.
• A linked list is a linear collection of data elements, called nodes, each
pointing to the next node by means of a pointer.
• Each node contains two fields: Data & Link (Address of next node).
• A linked list is represented by a pointer to the first node called as HEAD node.
• If the linked list is EMPTY, then, HEAD is NULL.
• Last node has NULL in the link field.
Why Linked List?
Arrays can be used to store linear data of similar types, but arrays have the following
limitations.
1) The size of the arrays is fixed: So we must know the upper limit on the number of
elements in advance. Also, generally, the allocated memory is equal to the upper limit
irrespective of the usage.
2) Inserting a new element in an array of elements is expensive because the room has to be
created for the new elements and to create room existing elements have to be shifted.
Disadvantages
• Random access is not allowed. We have to access elements sequentially
starting from the first node. So we cannot do binary search with linked lists
efficiently with its default implementation.
• Extra memory space for a pointer is required with each element of the list.
• Not cache friendly. Since array elements are contiguous locations, there is
locality of reference which is not there in case of linked lists.
Representation
• A linked list is represented by a pointer to the first node of the linked list.
The first node is called the HEAD.
• If the linked list is empty, then the value of the head is NULL.
} *head=NULL;
• Circular Linked List − Last item contains link of the first element as
next and the first element has a link to the last element as previous.
18
Recommended Reading
Textbooks:
• Yashwant Kanetkar,”Data Structure using C”, BPB Publication, 5th Edition ,2011
• A.Tannenbaum,Y. Lanhgsam and A.J. Augenstein ,” Data Structures Using C And C++ “,Prentice Hall of
India,2nd Edition,2009.
• Jean-Paul Tremblay, P.G Sorenson, “An Introduction to Data Structures with applications”, Mcgraw-Hill
,2nd Edition ,1984.
Reference Book:
• Robert L Kruse, “Data Structure and Program Design in C”, Prentice Hall (1991).
• Noel Kalicharan ,“Data Structure in C” ,Ist Edition Create space publisher, 2008.
• Mark Allen Weiss,“Data Structure and algorithm Analysis in C”,2nd Edition AddisonWesley,1996.
• E. Balagurusamy, “Problem Solving through C language”, TMH publication, Fourth Edition, 2008.
• R.S Salaria ,“Data Structures & Algorithms using C”,Khanna Publication,4th Edition,2009
• E.Horowitz and S.Sahni,”Fundamentals of Data Structures in C “,2nd Edition, Universities
Press,2008.
Thank you !