SlideShare a Scribd company logo
DATA STRUCTURE AND
ALGORITHM
Data Structures is about how data can be stored in different structures.
Algorithms is about how to solve different problems, often by searching through and
manipulating data structures.
Theory about Data Structures and Algorithms (DSA) helps us to use large amounts of data to
solve problems efficiently.
We structure data in different ways depending on what data we have, and what we want to do
with it.
DATA STRUCTURE & ALGORITHM
WHAT IS DSA?
Data Structures and Algorithms (DSA) refer to the study of methods for organizing and storing data and the design of
procedures (algorithms) for solving problems, which operate on these data structures.
DATA
STRUCTURES
PRIMARY DATA
STRUCTURES
SECONDARY DATA
STRUCTURES
INT, CHAR,FLOAT
DOUBLE
LINEAR
DATA
STRUCTURE
S
NON LINEAR
DATA
STRUCTURES
LIST
S
ARRAY
S
STACK
S
QUEUE
S
TREE
S
GRAPH
S
CLASSIFICATION OF DATA STRUCTURE:
Primitive data
type Non- primitive or
Abstract data type
Primary Data Strucutres/Primitive Data Structures:
Primitive data structures include all the fundamental data structures that can be directly manipulated by machine-level
instructions. Some of the common primitive data structures include integer, character, real, boolean etc
Secondary Data Structures/Non Primitive Data Structures:
Non primitive data structures, refer to all those data structures that are derived from one or more primitive data structures.
The objective of creating non-primitive data structures is to form sets of homogeneous or heterogeneous data elements.
Linear Data Structures:
Linear data structures are data strucutres in which, all the data elements are arranged in i, linear or sequential fashion.
Examples of data structures include arrays, stacks, queues, linked lists, etc.
Non Linear Structures:
In non-linear data strucutres, there is definite order or sequence in which data elements are arranged. For instance, a non-
linear data structures could arrange data elements in a hierarchical fashion. Examples of non-linear data structures are trees
and graphs.
Static and dynamic data structure:
Static data structure:
If a data structure is created using static memory allocation, ie. data structure formed when the number of
data items are known in advance ,it is known as static data static data structure or fixed size data structure.
Dynamic data structure:
If the data structure is created using dynamic memory allocation i.e data structure formed when the number
of data items are not known in advance is known as dynamic data structure or variable size data structure.
Array
Array is a linear data structure that stores a collection of elements of the same data type. Elements are
allocated contiguous memory, allowing for constant-time access. Each element has a unique index
number.
Operations on Array:
Traversal: Iterating through the elements of an array.
Insertion: Adding an element to the array at a specific index.
Deletion: Removing an element from the array at a specific index.
Searching: Finding an element in the array by its value or index.
Types of Arrays:
One-dimensional array: A simple array with a single dimension.
Multidimensional array: An array with multiple dimensions, such as a matrix.
Applications of Array:
Storing data in a sequential manner
Implementing queues, stacks, and other data structures
Representing matrices and tables
Array Implementation of list:
Array is a collection of specific number of same type of data stored in consecutive memory locations.
Array is a static data structure i.e., the memory should be allocated in advance and the size is fixed. This
will waste the memory space when used space is less than the allocated space.
Insertion and Deletion operation are expensive as it requires more data movements Find and Print list
operations takes constant time.
The basic operations performed on a list of elements are
a. Creation of List.
b. Insertion of data in the List
c.Deletion of data from the List
d.Display all data s in the List
‟
e.Searching for a data in the list
Declaration of Array:
#define maxsize 10 int list[maxsize], n ; Create Operation:
Create operation is used to create the list with „ n „ number of elements .If „ n „ exceeds the array s maxsize, then
‟
elements cannot be inserted into the list. Otherwise the array elements are stored in the consecutive array locations
(i.e.) list [0], list [1] and so on.
void Create ( )
{
int i;
printf("nEnter the number of elements to be added in the list:t"); scanf("%d",&n);
printf("nEnter the array elements:t"); for(i=0;i<n;i++)
scanf("%d",&list[i]);
}
If n=6, the output of creation is as follows:
list[6]
Insert Operation:
Insert operation is used to insert an element at particular position in the existing list. Inserting the element in
the last position of an array is easy. But inserting the element at a particular position in an array is quite
difficult since it involves all the subsequent elements to be shifted one position to the right.
Routine to insert an element in the array:
void Insert( )
{
int i,data,pos;
printf("nEnter the data to be inserted:t"); scanf("%d",&data);
printf("nEnter the position at which element to be inserted:t"); scanf("%d",&pos);
if (pos==n)
printf (“Array overflow”); for(i = n-1 ; i >= pos-1 ; i--)
list[i+1] = list[i]; list[pos-1] = data; n=n+1;
Display();}
Consider an array with 5 elements [ max elements = 10 ]
10 20 30 40 50
1
0
2
0
3
0
4
0
5
0
If data 15 is to be inserted in the 2nd
position then 50 has to be moved to next index position, 40 has to be
moved to 50 position, 30 has to be moved to 40 position and 20 has to be moved to 30 position.
1
0
2
0
3
0
4
0
5
0
1
0
2
0
3
0
4
0
5
0
After this four data movement, 15 is inserted in the 2nd
position of the array.
1
0
1
5
2
0
3
0
4
0
5
0
Deletion Operation:
Deletion is the process of removing an element from the array at any position.
Deleting an element from the end is easy. If an element is to be deleted from any particular
position ,it requires all subsequent element from that position is shifted one position towards left.
Routine to delete an element in the array:
void Delete( )
{
int i, pos ;
printf("nEnter the position of the data to be deleted:t"); scanf("%d",&pos);
printf("nThe data deleted is:t %d", list[pos-1]); for(i=pos-1;i<n-1;i++)
list[i]=list[i+1]; n=n-1;
Display();
}
Consider an array with 5 elements [ max elements = 10 ]
1
0
2
0
3
0
4
0
5
0
If data 20 is to be deleted from the array, then 30 has to be moved to data 20 position, 40 has to
be moved to data 30 position and 50 has to be moved to data 40 position.
1
0
2
0
3
0
4
0
5
0
After this 3 data movements, data 20 is deleted from the 2nd
position of the array.
1
0
3
0
4
0
5
0
Display Operation/Traversing a list
Traversal is the process of visiting the elements in a array.
Display( ) operation is used to display all the elements stored in the list. The elements are stored from the
index 0 to n - 1. Using a for loop, the elements in the list are viewed
Routine to traverse/display elements of the array:
void display( )
{
int i;
printf("n**********Elements in the array**********n"); for(i=0;i<n;i++)
printf("%dt",list[i]);
}
Search Operation:
Search( ) operation is used to determine whether a particular element is present in the list or not. Input
the search element to be checked in the list.
Routine to search an element in the array:
void Search( )
{
int search,i,count = 0;
printf("nEnter the element to be searched:t"); scanf("%d",&search);
for(i=0;i<n;i++)
{
if(search == list[i]) count++;
}
if(count==0)
printf("nElement not present in the list"); else
printf("nElement present in the list");
}
Linked Lists:
A linked list is a linear data structure that stores data in nodes, which are connected by pointers. Unlike arrays,
linked lists are not stored in contiguous memory locations.
Characteristics of Linked List:
• Dynamic: Linked lists can be easily resized by adding or removing nodes.
• Non-contiguous: Nodes are stored in random memory locations and connected by pointers.
• Sequential access: Nodes can only be accessed sequentially, starting from the head of the list.
Operations on Linked List:
• Creation: Creating a new linked list or adding a new node to an existing list.
• Traversal: Iterating through the list and accessing each node.
• Insertion: Adding a new node at a specific position in the list.
• Deletion: Removing a node from the list.
• Search: Finding a node with a specific value in the list.
Types of Linked List:
Singly Linked List: Each node points to the next node in the list.
Doubly Linked List: Each node points to both the next and previous nodes in the list.
Circular Linked List: The last node points back to the first node, forming a circular loop.
Singly Linked List:
Singly linked list is a linear data structure in which the elements are not stored in contiguous memory
locations and each element is connected only to its next element using a pointer.
Linked List is a linear data structure, in which elements are not stored at a contiguous location,
rather they are linked using pointers. Linked List forms a series of connected nodes, where each
node stores the data and the address of the next node.
Node Structure: A node in a linked list typically consists of two components:
1.Data: It holds the actual value or data associated with the node.
2.Next Pointer or Reference : It stores the memory address (reference) of the next node in the
sequence.
Head and Tail: The linked list is accessed through the head node, which points to the first node in the
list. The last node in the list points to NULL or nullptr, indicating the end of the list. This node is known
as the tail node.
Double-linked list:
In a doubly linked list, each node contains references to both the next and previous nodes. This allows
for traversal in both forward and backward directions, but it requires additional memory for the
backward reference.
Circular linked list:
In a circular linked list, the last node points back to the head node, creating a circular structure.
It can be either singly or doubly linked.
Operations on Linked Lists
1.Insertion: Adding a new node to a linked list involves adjusting the pointers of the existing nodes to
maintain the proper sequence. Insertion can be performed at the beginning, end, or any position within
the list
2.Deletion: Removing a node from a linked list requires adjusting the pointers of the neighboring nodes
to bridge the gap left by the deleted node. Deletion can be performed at the beginning, end, or any
position within the list.
3.Searching: Searching for a specific value in a linked list involves traversing the list from the head
node until the value is found or the end of the list is reached.
Ad

Recommended

PPTX
8.DATA STRUCTURES UNIT 1 AND 2 CS3301PPT.pptx
venigkrish89
 
PPTX
Data Structures and algoithms Unit - 1.pptx
mexiuro901
 
PPT
LINKEDb2bb22bb3b3b3b3n3_LIST_UKL_1-2.ppt
Farhana859326
 
PPTX
EC2311 – Data Structures and C Programming
Padma Priya
 
PPTX
21CS32 DS Module 1 PPT.pptx
reddy19841
 
PPTX
datastructureppt-190327174340 (1).pptx
DEEPAK948083
 
DOCX
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Malikireddy Bramhananda Reddy
 
PPT
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCE
Venugopalavarma Raja
 
PPTX
Data Structure Introduction- Arrays, Matrix, Linked List
JasmineJinitha
 
PDF
DSA UNIT II ARRAY AND LIST - notes
swathirajstar
 
PPTX
Data Structures (CS8391)
Elavarasi K
 
PDF
unit-ids17-180709051413-1.pdf
KarthiKeyan326587
 
PDF
DS Complete notes for Computer science and Engineering
RAJASEKHARV8
 
PDF
UNITIII LDS.pdf
meenamadhuvandhi2
 
PPTX
DSA - Copy.pptx
BishalChowdhury10
 
PDF
Data structure ppt
Prof. Dr. K. Adisesha
 
PPTX
General Data structures
Youssef Elsalhawy
 
PPTX
DS Module 1.pptx
sarala9
 
PPT
1 list datastructures
Nguync91368
 
PPT
Unit ii(dsc++)
Durga Devi
 
PPT
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
yarotos643
 
PPT
1597380885789.ppt
PraveenKumar977108
 
PPTX
DS Module 1.pptx
SaralaT3
 
PPT
intr_ds.ppt
PrakharNamdev3
 
PPTX
C++ Data Structure PPT.pptx
Mukesh Thakur
 
PPTX
Adt of lists
Nivegeetha
 
PPTX
Data structure and its types.
buyinstagramfollowersaustralia
 
PPTX
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
PPTX
Bitumen Emulsion by Dr Sangita Ex CRRI Delhi
grilcodes
 

More Related Content

Similar to DATA STRUCTURE AND ALGORITHM with linked list (20)

PPTX
Data Structure Introduction- Arrays, Matrix, Linked List
JasmineJinitha
 
PDF
DSA UNIT II ARRAY AND LIST - notes
swathirajstar
 
PPTX
Data Structures (CS8391)
Elavarasi K
 
PDF
unit-ids17-180709051413-1.pdf
KarthiKeyan326587
 
PDF
DS Complete notes for Computer science and Engineering
RAJASEKHARV8
 
PDF
UNITIII LDS.pdf
meenamadhuvandhi2
 
PPTX
DSA - Copy.pptx
BishalChowdhury10
 
PDF
Data structure ppt
Prof. Dr. K. Adisesha
 
PPTX
General Data structures
Youssef Elsalhawy
 
PPTX
DS Module 1.pptx
sarala9
 
PPT
1 list datastructures
Nguync91368
 
PPT
Unit ii(dsc++)
Durga Devi
 
PPT
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
yarotos643
 
PPT
1597380885789.ppt
PraveenKumar977108
 
PPTX
DS Module 1.pptx
SaralaT3
 
PPT
intr_ds.ppt
PrakharNamdev3
 
PPTX
C++ Data Structure PPT.pptx
Mukesh Thakur
 
PPTX
Adt of lists
Nivegeetha
 
PPTX
Data structure and its types.
buyinstagramfollowersaustralia
 
Data Structure Introduction- Arrays, Matrix, Linked List
JasmineJinitha
 
DSA UNIT II ARRAY AND LIST - notes
swathirajstar
 
Data Structures (CS8391)
Elavarasi K
 
unit-ids17-180709051413-1.pdf
KarthiKeyan326587
 
DS Complete notes for Computer science and Engineering
RAJASEKHARV8
 
UNITIII LDS.pdf
meenamadhuvandhi2
 
DSA - Copy.pptx
BishalChowdhury10
 
Data structure ppt
Prof. Dr. K. Adisesha
 
General Data structures
Youssef Elsalhawy
 
DS Module 1.pptx
sarala9
 
1 list datastructures
Nguync91368
 
Unit ii(dsc++)
Durga Devi
 
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
yarotos643
 
1597380885789.ppt
PraveenKumar977108
 
DS Module 1.pptx
SaralaT3
 
intr_ds.ppt
PrakharNamdev3
 
C++ Data Structure PPT.pptx
Mukesh Thakur
 
Adt of lists
Nivegeetha
 
Data structure and its types.
buyinstagramfollowersaustralia
 

Recently uploaded (20)

PPTX
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
PPTX
Bitumen Emulsion by Dr Sangita Ex CRRI Delhi
grilcodes
 
PPTX
Deep Learning for Image Processing on 16 June 2025 MITS.pptx
resming1
 
PDF
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Mark Billinghurst
 
PPTX
Stability of IBR Dominated Grids - IEEE PEDG 2025 - short.pptx
ssuser307730
 
PPTX
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
 
PDF
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
hosseinihamid192023
 
PDF
Rapid Prototyping for XR: Lecture 3 - Video and Paper Prototyping
Mark Billinghurst
 
PPTX
Structural Wonderers_new and ancient.pptx
nikopapa113
 
PPTX
NEW Strengthened Senior High School Gen Math.pptx
DaryllWhere
 
PPTX
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
SAMEER VISHWAKARMA
 
PPT
20CE404-Soil Mechanics - Slide Share PPT
saravananr808639
 
PPTX
AI_Presentation (1). Artificial intelligence
RoselynKaur8thD34
 
PDF
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
IJDKP
 
PPTX
FSE_LLM4SE1_A Tool for In-depth Analysis of Code Execution Reasoning of Large...
cl144
 
PDF
International Journal of Advanced Information Technology (IJAIT)
ijait
 
PDF
Proposal for folders structure division in projects.pdf
Mohamed Ahmed
 
PDF
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Mark Billinghurst
 
PPTX
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
 
PDF
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Diego López-de-Ipiña González-de-Artaza
 
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
Bitumen Emulsion by Dr Sangita Ex CRRI Delhi
grilcodes
 
Deep Learning for Image Processing on 16 June 2025 MITS.pptx
resming1
 
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Mark Billinghurst
 
Stability of IBR Dominated Grids - IEEE PEDG 2025 - short.pptx
ssuser307730
 
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
 
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
hosseinihamid192023
 
Rapid Prototyping for XR: Lecture 3 - Video and Paper Prototyping
Mark Billinghurst
 
Structural Wonderers_new and ancient.pptx
nikopapa113
 
NEW Strengthened Senior High School Gen Math.pptx
DaryllWhere
 
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
SAMEER VISHWAKARMA
 
20CE404-Soil Mechanics - Slide Share PPT
saravananr808639
 
AI_Presentation (1). Artificial intelligence
RoselynKaur8thD34
 
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
IJDKP
 
FSE_LLM4SE1_A Tool for In-depth Analysis of Code Execution Reasoning of Large...
cl144
 
International Journal of Advanced Information Technology (IJAIT)
ijait
 
Proposal for folders structure division in projects.pdf
Mohamed Ahmed
 
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Mark Billinghurst
 
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
 
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Diego López-de-Ipiña González-de-Artaza
 
Ad

DATA STRUCTURE AND ALGORITHM with linked list

  • 2. Data Structures is about how data can be stored in different structures. Algorithms is about how to solve different problems, often by searching through and manipulating data structures. Theory about Data Structures and Algorithms (DSA) helps us to use large amounts of data to solve problems efficiently. We structure data in different ways depending on what data we have, and what we want to do with it.
  • 3. DATA STRUCTURE & ALGORITHM WHAT IS DSA? Data Structures and Algorithms (DSA) refer to the study of methods for organizing and storing data and the design of procedures (algorithms) for solving problems, which operate on these data structures.
  • 4. DATA STRUCTURES PRIMARY DATA STRUCTURES SECONDARY DATA STRUCTURES INT, CHAR,FLOAT DOUBLE LINEAR DATA STRUCTURE S NON LINEAR DATA STRUCTURES LIST S ARRAY S STACK S QUEUE S TREE S GRAPH S CLASSIFICATION OF DATA STRUCTURE: Primitive data type Non- primitive or Abstract data type
  • 5. Primary Data Strucutres/Primitive Data Structures: Primitive data structures include all the fundamental data structures that can be directly manipulated by machine-level instructions. Some of the common primitive data structures include integer, character, real, boolean etc Secondary Data Structures/Non Primitive Data Structures: Non primitive data structures, refer to all those data structures that are derived from one or more primitive data structures. The objective of creating non-primitive data structures is to form sets of homogeneous or heterogeneous data elements. Linear Data Structures: Linear data structures are data strucutres in which, all the data elements are arranged in i, linear or sequential fashion. Examples of data structures include arrays, stacks, queues, linked lists, etc. Non Linear Structures: In non-linear data strucutres, there is definite order or sequence in which data elements are arranged. For instance, a non- linear data structures could arrange data elements in a hierarchical fashion. Examples of non-linear data structures are trees and graphs.
  • 6. Static and dynamic data structure: Static data structure: If a data structure is created using static memory allocation, ie. data structure formed when the number of data items are known in advance ,it is known as static data static data structure or fixed size data structure. Dynamic data structure: If the data structure is created using dynamic memory allocation i.e data structure formed when the number of data items are not known in advance is known as dynamic data structure or variable size data structure.
  • 7. Array Array is a linear data structure that stores a collection of elements of the same data type. Elements are allocated contiguous memory, allowing for constant-time access. Each element has a unique index number. Operations on Array: Traversal: Iterating through the elements of an array. Insertion: Adding an element to the array at a specific index. Deletion: Removing an element from the array at a specific index. Searching: Finding an element in the array by its value or index. Types of Arrays: One-dimensional array: A simple array with a single dimension. Multidimensional array: An array with multiple dimensions, such as a matrix. Applications of Array: Storing data in a sequential manner Implementing queues, stacks, and other data structures Representing matrices and tables
  • 8. Array Implementation of list: Array is a collection of specific number of same type of data stored in consecutive memory locations. Array is a static data structure i.e., the memory should be allocated in advance and the size is fixed. This will waste the memory space when used space is less than the allocated space. Insertion and Deletion operation are expensive as it requires more data movements Find and Print list operations takes constant time. The basic operations performed on a list of elements are a. Creation of List. b. Insertion of data in the List
  • 9. c.Deletion of data from the List d.Display all data s in the List ‟ e.Searching for a data in the list Declaration of Array: #define maxsize 10 int list[maxsize], n ; Create Operation: Create operation is used to create the list with „ n „ number of elements .If „ n „ exceeds the array s maxsize, then ‟ elements cannot be inserted into the list. Otherwise the array elements are stored in the consecutive array locations (i.e.) list [0], list [1] and so on. void Create ( ) { int i; printf("nEnter the number of elements to be added in the list:t"); scanf("%d",&n); printf("nEnter the array elements:t"); for(i=0;i<n;i++) scanf("%d",&list[i]); } If n=6, the output of creation is as follows: list[6]
  • 10. Insert Operation: Insert operation is used to insert an element at particular position in the existing list. Inserting the element in the last position of an array is easy. But inserting the element at a particular position in an array is quite difficult since it involves all the subsequent elements to be shifted one position to the right. Routine to insert an element in the array: void Insert( ) { int i,data,pos; printf("nEnter the data to be inserted:t"); scanf("%d",&data); printf("nEnter the position at which element to be inserted:t"); scanf("%d",&pos); if (pos==n) printf (“Array overflow”); for(i = n-1 ; i >= pos-1 ; i--) list[i+1] = list[i]; list[pos-1] = data; n=n+1; Display();} Consider an array with 5 elements [ max elements = 10 ] 10 20 30 40 50
  • 11. 1 0 2 0 3 0 4 0 5 0 If data 15 is to be inserted in the 2nd position then 50 has to be moved to next index position, 40 has to be moved to 50 position, 30 has to be moved to 40 position and 20 has to be moved to 30 position. 1 0 2 0 3 0 4 0 5 0 1 0 2 0 3 0 4 0 5 0 After this four data movement, 15 is inserted in the 2nd position of the array. 1 0 1 5 2 0 3 0 4 0 5 0
  • 12. Deletion Operation: Deletion is the process of removing an element from the array at any position. Deleting an element from the end is easy. If an element is to be deleted from any particular position ,it requires all subsequent element from that position is shifted one position towards left. Routine to delete an element in the array: void Delete( ) { int i, pos ; printf("nEnter the position of the data to be deleted:t"); scanf("%d",&pos); printf("nThe data deleted is:t %d", list[pos-1]); for(i=pos-1;i<n-1;i++) list[i]=list[i+1]; n=n-1; Display(); }
  • 13. Consider an array with 5 elements [ max elements = 10 ] 1 0 2 0 3 0 4 0 5 0 If data 20 is to be deleted from the array, then 30 has to be moved to data 20 position, 40 has to be moved to data 30 position and 50 has to be moved to data 40 position. 1 0 2 0 3 0 4 0 5 0 After this 3 data movements, data 20 is deleted from the 2nd position of the array. 1 0 3 0 4 0 5 0
  • 14. Display Operation/Traversing a list Traversal is the process of visiting the elements in a array. Display( ) operation is used to display all the elements stored in the list. The elements are stored from the index 0 to n - 1. Using a for loop, the elements in the list are viewed Routine to traverse/display elements of the array: void display( ) { int i; printf("n**********Elements in the array**********n"); for(i=0;i<n;i++) printf("%dt",list[i]); }
  • 15. Search Operation: Search( ) operation is used to determine whether a particular element is present in the list or not. Input the search element to be checked in the list. Routine to search an element in the array: void Search( ) { int search,i,count = 0; printf("nEnter the element to be searched:t"); scanf("%d",&search); for(i=0;i<n;i++) { if(search == list[i]) count++; } if(count==0) printf("nElement not present in the list"); else printf("nElement present in the list"); }
  • 16. Linked Lists: A linked list is a linear data structure that stores data in nodes, which are connected by pointers. Unlike arrays, linked lists are not stored in contiguous memory locations. Characteristics of Linked List: • Dynamic: Linked lists can be easily resized by adding or removing nodes. • Non-contiguous: Nodes are stored in random memory locations and connected by pointers. • Sequential access: Nodes can only be accessed sequentially, starting from the head of the list. Operations on Linked List: • Creation: Creating a new linked list or adding a new node to an existing list. • Traversal: Iterating through the list and accessing each node. • Insertion: Adding a new node at a specific position in the list. • Deletion: Removing a node from the list. • Search: Finding a node with a specific value in the list.
  • 17. Types of Linked List: Singly Linked List: Each node points to the next node in the list. Doubly Linked List: Each node points to both the next and previous nodes in the list. Circular Linked List: The last node points back to the first node, forming a circular loop. Singly Linked List: Singly linked list is a linear data structure in which the elements are not stored in contiguous memory locations and each element is connected only to its next element using a pointer.
  • 18. Linked List is a linear data structure, in which elements are not stored at a contiguous location, rather they are linked using pointers. Linked List forms a series of connected nodes, where each node stores the data and the address of the next node.
  • 19. Node Structure: A node in a linked list typically consists of two components: 1.Data: It holds the actual value or data associated with the node. 2.Next Pointer or Reference : It stores the memory address (reference) of the next node in the sequence. Head and Tail: The linked list is accessed through the head node, which points to the first node in the list. The last node in the list points to NULL or nullptr, indicating the end of the list. This node is known as the tail node. Double-linked list: In a doubly linked list, each node contains references to both the next and previous nodes. This allows for traversal in both forward and backward directions, but it requires additional memory for the backward reference.
  • 20. Circular linked list: In a circular linked list, the last node points back to the head node, creating a circular structure. It can be either singly or doubly linked.
  • 21. Operations on Linked Lists 1.Insertion: Adding a new node to a linked list involves adjusting the pointers of the existing nodes to maintain the proper sequence. Insertion can be performed at the beginning, end, or any position within the list 2.Deletion: Removing a node from a linked list requires adjusting the pointers of the neighboring nodes to bridge the gap left by the deleted node. Deletion can be performed at the beginning, end, or any position within the list. 3.Searching: Searching for a specific value in a linked list involves traversing the list from the head node until the value is found or the end of the list is reached.