SlideShare a Scribd company logo
OBJECTIVES:
• To understand the ADTs and its implementation.
• To apply sorting and searching techniques
• To learn and understand the design techniques in algorithms.
• To understand the efficiency of the algorithmic techniques.
TEXT BOOK:
1. Mark Allen Weiss, “Data structures and Algorithm Analysis in
C”,Addison Wesley, Second Edition,2007.
2. Anany Levitin,“Introduction to the Design and Analysis of
Algorithms”,Pearson Education,Third Edition,2012.
CS4301 DATA STRUCTURES AND ALGORITHMS I
UNIT I- INTRODUCTION TO DATA
STRUCTURES
Abstract Data Types (ADTs) – List ADT – array-
based implementation – linked list
implementation –– singly linked lists- doubly-
linked lists –circularly linked lists- applications
of lists –Polynomial Manipulation.
DATA STRUCTURE
Definition
• A data structure is a particular way of storing and
organizing data either in computer’s memory or on the
disk storage so that it can be used efficiently.
Applications of Data Structures
❖ Compiler design
❖ Operating system
❖ Statistical analysis package
❖ DBMS
❖ Numerical analysis
❖ Simulation
❖ Artificial Intelligence
CLASSIFICATION OF DATA STRUCTURES
LINEAR DATA STRUCTURES
• If the elements of a data structure are stored in a linear
or sequential order, then it is a linear data structure.
– Examples include arrays, linked lists, stacks, and queues.
• Linear data structures can be represented in memory in
two different ways.
– linear relationship between elements by means of
sequential memory locationsarray
– linear relationship between elements by means of
linkslinked list.
NON-LINEAR DATA STRUCTURES
• If the elements of a data structure are not stored in a
sequential order, then it is a non-linear data structure.
The relationship of adjacency is not maintained
between elements of a non-linear data structure.
– Examples include trees and graphs.
ABSTRACT DATA TYPE
An abstract data type (ADT) is the way we look at a data
structure, focusing on what it does and ignoring how it does its job.
• Abstract data type operations are
– Create, Display, Insertion, deletion, Modification
• Advantage of using ADTs
– It is reusable, robust
– It can be re-used at several places and it reduces coding efforts
– Encapsulation ensures that data cannot be corrupted
– The Working of various integrated operation cannot be tampered
with by the application program
– ADT ensures a robust data structure
List ADT
• List is an ordered set of elements.
• The general form of the list is A1, A2, A3, ..... ,AN
A1 - First element of the list
AN - Last element of the list
N - Size of the list
• If the element at position i is Ai then its successor is Ai+1
and its predecessor is Ai-1.
Various operations performed on List
• create -create a list
• printList() – prints all elements in the list
• find(x) – returns the position of the first occurrence of x
• insert(x, position) – inserts x into the list at the specified position
• delete (X) - The element X is deleted
• isEmpty( ) – returns true if the list has no elements
• makeEmpty( ) – Makes the list empty
• Next (i) - Returns the position of its successor element i+1.
• Previous (i)- Returns the position of its predecessor i-1
unit 1_Linked list.pptx
Implementation of list ADT:
• 1. Array based Implementation
• 2. Linked List based implementation
Array Implementation of list:
• Array is a collection of specific number of
same type of data stored in consecutive
memory locations.
• The basic operations performed on a list of
elements are
– 1. Creation of List.
– 2. Insertion of data in the List
– 3. Deletion of data from the List
– 4. Display all data in the List
– 5. Searching for a data in the list
Declaration of Array:
#define maxsize 10
int list[maxsize], n ;
Creation of Array
unit 1_Linked list.pptx
Insert Operation: Insert operation is used to insert an element at
particular position in the existing list.
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();
}
unit 1_Linked list.pptx
Deletion
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();
}
unit 1_Linked list.pptx
Search Operation:
Routine to search an element in the array:
void Search( )
{
int search,i;
printf("nEnter the element to be searched:t");
scanf("%d",&search);
for(i=0;i<n;i++)
{
if(list[i]==search)
{
printf("Value is in the %d Position", i);
}
else
{
printf("Value %d is not in the list::", search);
continue;
}

More Related Content

PPTX
Data structures - unit 1
PPTX
DS Module 1.pptx
PPTX
DS Module 1.pptx
PPTX
DSA - Copy.pptx
PDF
UNITIII LDS.pdf
PPTX
EC2311 – Data Structures and C Programming
DOCX
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
PDF
Unit.1 Introduction to Data Structuresres
Data structures - unit 1
DS Module 1.pptx
DS Module 1.pptx
DSA - Copy.pptx
UNITIII LDS.pdf
EC2311 – Data Structures and C Programming
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Unit.1 Introduction to Data Structuresres

Similar to unit 1_Linked list.pptx (20)

PPT
The Stack in Data structure and algorithm
PPTX
8.DATA STRUCTURES UNIT 1 AND 2 CS3301PPT.pptx
PPTX
DataStructurePpt.pptx
PDF
M v bramhananda reddy dsa complete notes
PPTX
Data Structures (CS8391)
PDF
unit-ids17-180709051413-1.pdf
PPTX
Introduction to Data Structures and their importance
PPTX
Data Structures and algoithms Unit - 1.pptx
PPTX
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
PPTX
DATA STRUCTURE AND ALGORITHM with linked list
PPTX
ntroduction of Algorithms, Analysing Algorithms. Arrays: Sparse Matrices - Re...
PDF
Data Structure Ppt for our engineering college industrial training.
PPTX
DataStructureccvdgddfffdesddsssdssPpt.pptx
PPTX
Dsa unit 1
DOC
data structures and algorithm Cha 1and 2.doc
PPT
Intro ds
PPT
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCE
PPTX
Chapter 1 _edited.pptx.software engineering
PDF
UNIT I - Data Structures.pdf
PPTX
Introduction to Data Structure
The Stack in Data structure and algorithm
8.DATA STRUCTURES UNIT 1 AND 2 CS3301PPT.pptx
DataStructurePpt.pptx
M v bramhananda reddy dsa complete notes
Data Structures (CS8391)
unit-ids17-180709051413-1.pdf
Introduction to Data Structures and their importance
Data Structures and algoithms Unit - 1.pptx
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
DATA STRUCTURE AND ALGORITHM with linked list
ntroduction of Algorithms, Analysing Algorithms. Arrays: Sparse Matrices - Re...
Data Structure Ppt for our engineering college industrial training.
DataStructureccvdgddfffdesddsssdssPpt.pptx
Dsa unit 1
data structures and algorithm Cha 1and 2.doc
Intro ds
ARRAYS IN C++ CBSE AND STATE +2 COMPUTER SCIENCE
Chapter 1 _edited.pptx.software engineering
UNIT I - Data Structures.pdf
Introduction to Data Structure

Recently uploaded (20)

PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Current and future trends in Computer Vision.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
DOCX
573137875-Attendance-Management-System-original
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPT
Mechanical Engineering MATERIALS Selection
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Geodesy 1.pptx...............................................
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
Well-logging-methods_new................
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Current and future trends in Computer Vision.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
573137875-Attendance-Management-System-original
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Mechanical Engineering MATERIALS Selection
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
bas. eng. economics group 4 presentation 1.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Geodesy 1.pptx...............................................
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
CH1 Production IntroductoryConcepts.pptx
R24 SURVEYING LAB MANUAL for civil enggi
OOP with Java - Java Introduction (Basics)
Embodied AI: Ushering in the Next Era of Intelligent Systems
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Well-logging-methods_new................

unit 1_Linked list.pptx

  • 1. OBJECTIVES: • To understand the ADTs and its implementation. • To apply sorting and searching techniques • To learn and understand the design techniques in algorithms. • To understand the efficiency of the algorithmic techniques. TEXT BOOK: 1. Mark Allen Weiss, “Data structures and Algorithm Analysis in C”,Addison Wesley, Second Edition,2007. 2. Anany Levitin,“Introduction to the Design and Analysis of Algorithms”,Pearson Education,Third Edition,2012. CS4301 DATA STRUCTURES AND ALGORITHMS I
  • 2. UNIT I- INTRODUCTION TO DATA STRUCTURES Abstract Data Types (ADTs) – List ADT – array- based implementation – linked list implementation –– singly linked lists- doubly- linked lists –circularly linked lists- applications of lists –Polynomial Manipulation.
  • 3. DATA STRUCTURE Definition • A data structure is a particular way of storing and organizing data either in computer’s memory or on the disk storage so that it can be used efficiently. Applications of Data Structures ❖ Compiler design ❖ Operating system ❖ Statistical analysis package ❖ DBMS ❖ Numerical analysis ❖ Simulation ❖ Artificial Intelligence
  • 5. LINEAR DATA STRUCTURES • If the elements of a data structure are stored in a linear or sequential order, then it is a linear data structure. – Examples include arrays, linked lists, stacks, and queues. • Linear data structures can be represented in memory in two different ways. – linear relationship between elements by means of sequential memory locationsarray – linear relationship between elements by means of linkslinked list. NON-LINEAR DATA STRUCTURES • If the elements of a data structure are not stored in a sequential order, then it is a non-linear data structure. The relationship of adjacency is not maintained between elements of a non-linear data structure. – Examples include trees and graphs.
  • 6. ABSTRACT DATA TYPE An abstract data type (ADT) is the way we look at a data structure, focusing on what it does and ignoring how it does its job. • Abstract data type operations are – Create, Display, Insertion, deletion, Modification • Advantage of using ADTs – It is reusable, robust – It can be re-used at several places and it reduces coding efforts – Encapsulation ensures that data cannot be corrupted – The Working of various integrated operation cannot be tampered with by the application program – ADT ensures a robust data structure
  • 7. List ADT • List is an ordered set of elements. • The general form of the list is A1, A2, A3, ..... ,AN A1 - First element of the list AN - Last element of the list N - Size of the list • If the element at position i is Ai then its successor is Ai+1 and its predecessor is Ai-1.
  • 8. Various operations performed on List • create -create a list • printList() – prints all elements in the list • find(x) – returns the position of the first occurrence of x • insert(x, position) – inserts x into the list at the specified position • delete (X) - The element X is deleted • isEmpty( ) – returns true if the list has no elements • makeEmpty( ) – Makes the list empty • Next (i) - Returns the position of its successor element i+1. • Previous (i)- Returns the position of its predecessor i-1
  • 10. Implementation of list ADT: • 1. Array based Implementation • 2. Linked List based implementation
  • 11. Array Implementation of list: • Array is a collection of specific number of same type of data stored in consecutive memory locations. • The basic operations performed on a list of elements are – 1. Creation of List. – 2. Insertion of data in the List – 3. Deletion of data from the List – 4. Display all data in the List – 5. Searching for a data in the list
  • 12. Declaration of Array: #define maxsize 10 int list[maxsize], n ; Creation of Array
  • 14. Insert Operation: Insert operation is used to insert an element at particular position in the existing list. 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(); }
  • 16. Deletion 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(); }
  • 18. Search Operation: Routine to search an element in the array: void Search( ) { int search,i; printf("nEnter the element to be searched:t"); scanf("%d",&search); for(i=0;i<n;i++) { if(list[i]==search) { printf("Value is in the %d Position", i); } else { printf("Value %d is not in the list::", search); continue; }

Editor's Notes

  • #2: application: https://www.youtube.com/watch?v=d_XvFOkQz5k https://www.youtube.com/watch?v=PoxdkCSsD3A