SlideShare a Scribd company logo
Data Structures and Algorithms
An Introduction
Course Objectives
 Understanding the concepts of cost and benefits for data
structures
 Understand commonly used data structures
 Understand the effectiveness of data structure
 Select a data structure for specific requirement
 Implement data structures in a programming language
Agenda
 Introduction to Data Structures
 Importance and use of Data Structures
 Linked Lists
 Stack
 Queue
 Overview of Trees
 Overview of Graphs
 Sorting Algorithms
Session Agenda
 Need of Data Structures
 Data Structures Benefits
 Data Structures Terminologies
 Methodologies for Analyzing Algorithm
 Asymptotic Notations
 Types of Data Structures
 Linear
 Non Linear
Session Agenda
 Arrays
 Pointers
 Structures
 Linear Linked Lists
 Singly Linked Lists
 Doubly Linked Lists
 Circular Linked Lists ( Singly and Doubly)
Need for Data Structure
 Applications are Complex
 Complex Applications demand more Computations
 Computations require Complex Data
 Complex Data require Complex organization
 Complex Organizations require Complex Processing
(Searching, Insertion, Deletion)
 Data structures organize data
 Provides way of storing data so that it can be used efficiently
Selection of Data Structures
 The cost of a solution is the amount of resources
 The choice of data structure and algorithm can make the
difference in execution of a program
 Carefully chosen data structure will allow the most effective
algorithm to be used
 A well-designed data structure allows a variety of critical
operations to be performed, using few resources
 Quality and performance of the final result depends heavily
on choosing the best data structure
How to Select a data structure
 Analyze the problem to determine the resource constraints a
solution must meet
 Determine the basic operations that must be supported
 Quantify the resource constraints for each operation
 Select the data structure that best meets these
requirements
 Some questions to ask
 Amount of data to store
 Are all data inserted into the data structure at the beginning,
or are insertions interspersed with other operations?
 Can data be deleted? If so, a more complex representation is
typically required
 Are all data processed in some well-defined order, or is random
access allowed?
Data Structure Philosophy
 Each data structure has costs and benefits
 Rarely is one data structure better than another in all
situations.
 A data structure requires:
 space for each data item it stores
 time to perform each basic operation
 programming efforts
 Each problem has constraints on available space and time
 Only after a careful analysis of problem characteristics can
we know the best data structure for the task
Methodologies for Analyzing Algorithm
 How much of a computer time and memory is utilized by an
algorithm
 Methodologies
 Empirical Comparison (run programs)
 Asymptotic Algorithm Analysis
 The efficiency analysis concentrates on critical operations:
 data interchanges (swaps)
 comparisons (<, >, ==, ! =)
 arithmetic operations (+, -, =)
 Factors affecting running time
 Critical resources
 Size of the input
 Machine load
 Operating System, Compiler, …
 Problem size
Types of Data Structures
 Base Data Structures
 Primitive
 Composite
 Linear Data Structures
 Array
 Linked List
 Non-Linear Data Structures
 Graph
 Tree
Arrays
 Arrays are the most common data structure used to store
collections of elements
 Access any element using its index number
 Occupies contiguous memory area
 Example:
int scores[100];
scores[0] = 18;
scores[1] = 5;
scores[2] = 24;
scores
18 5 24 -2134 ... ... ... 14217
Index 0 1 2 3 . . . . . . . 99
Pointers
 A variable capable of storing an address is called a pointer
variable.
 Consider the variable declaration:
int *ptr;
 Such a pointer is said to "point to" an integer.
 Storing in ptr the address of an integer variable k is done as
ptr = &k;
 The "dereferencing operator" refers to the value of that
which ptr is pointing to.
*ptr = 7;
 To print to the screen the integer value stored at the address
pointed to by ptr.
printf("%dn",*ptr);
Structures
 We can declare the form of a block of data containing
different data types by means of a structure declaration.
 For example,
struct person
{
char name[20];
int age;
float weight;
};
 We now declare a variable of type person
struct person p;
 and access the structure data using this variable as
p.age
Structures Continued…
 We can also declare a pointer to a structure with the
declaration:
struct person *ptr;
 and we point it to our example structure with:
st_ptr = &p;
 Now, we can access a given member by de-referencing the
pointer as
(*st_ptr).age = 63;
 Or use an alternative syntax as
st_ptr->age = 63;

More Related Content

Similar to Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt

Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structure
chouguleamruta24
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
Rai University
 
DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS
Adams Sidibe
 
Data Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptxData Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptx
GIRISHKUMARBC1
 
Unit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data StructuresresUnit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data Structuresres
amplopsurat
 
Algorithms and Data Structures~hmftj
Algorithms and Data Structures~hmftjAlgorithms and Data Structures~hmftj
Algorithms and Data Structures~hmftj
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2
RajSingh734307
 
Lecture 1 and 2
Lecture 1 and 2Lecture 1 and 2
Lecture 1 and 2
SaheedTundeZubairSTA
 
Data Structure and its Fundamentals
Data Structure and its FundamentalsData Structure and its Fundamentals
Data Structure and its Fundamentals
Hitesh Mohapatra
 
1- Introduction.pptx.pdf
1- Introduction.pptx.pdf1- Introduction.pptx.pdf
1- Introduction.pptx.pdf
gm6523
 
Chapter 1- IT.pptx
Chapter 1- IT.pptxChapter 1- IT.pptx
Chapter 1- IT.pptx
ssuserb78e291
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
Abdul salam
 
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptxchapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
AmrutaNavale2
 
Chapter 1( intro &amp; overview)
Chapter 1( intro &amp; overview)Chapter 1( intro &amp; overview)
Chapter 1( intro &amp; overview)
MUHAMMAD AAMIR
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
JohnStuart83
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
Nimmi Weeraddana
 

Similar to Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt (20)

Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structure
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
 
DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS
 
Data Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptxData Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptx
 
Unit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data StructuresresUnit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data Structuresres
 
Algorithms and Data Structures~hmftj
Algorithms and Data Structures~hmftjAlgorithms and Data Structures~hmftj
Algorithms and Data Structures~hmftj
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2
 
Lect1.pptx
Lect1.pptxLect1.pptx
Lect1.pptx
 
Lect 1-2 Zaheer Abbas
Lect 1-2 Zaheer AbbasLect 1-2 Zaheer Abbas
Lect 1-2 Zaheer Abbas
 
Lecture 1 and 2
Lecture 1 and 2Lecture 1 and 2
Lecture 1 and 2
 
Data Structure and its Fundamentals
Data Structure and its FundamentalsData Structure and its Fundamentals
Data Structure and its Fundamentals
 
1- Introduction.pptx.pdf
1- Introduction.pptx.pdf1- Introduction.pptx.pdf
1- Introduction.pptx.pdf
 
Chapter 1- IT.pptx
Chapter 1- IT.pptxChapter 1- IT.pptx
Chapter 1- IT.pptx
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
 
Data Structures & Algorithms
Data Structures & AlgorithmsData Structures & Algorithms
Data Structures & Algorithms
 
Lect 1-2
Lect 1-2Lect 1-2
Lect 1-2
 
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptxchapter 1 Introduction to Ds and Algorithm Anyasis.pptx
chapter 1 Introduction to Ds and Algorithm Anyasis.pptx
 
Chapter 1( intro &amp; overview)
Chapter 1( intro &amp; overview)Chapter 1( intro &amp; overview)
Chapter 1( intro &amp; overview)
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
 

Recently uploaded

Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 

Recently uploaded (20)

Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 

Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt

  • 1. Data Structures and Algorithms An Introduction
  • 2. Course Objectives  Understanding the concepts of cost and benefits for data structures  Understand commonly used data structures  Understand the effectiveness of data structure  Select a data structure for specific requirement  Implement data structures in a programming language
  • 3. Agenda  Introduction to Data Structures  Importance and use of Data Structures  Linked Lists  Stack  Queue  Overview of Trees  Overview of Graphs  Sorting Algorithms
  • 4. Session Agenda  Need of Data Structures  Data Structures Benefits  Data Structures Terminologies  Methodologies for Analyzing Algorithm  Asymptotic Notations  Types of Data Structures  Linear  Non Linear
  • 5. Session Agenda  Arrays  Pointers  Structures  Linear Linked Lists  Singly Linked Lists  Doubly Linked Lists  Circular Linked Lists ( Singly and Doubly)
  • 6. Need for Data Structure  Applications are Complex  Complex Applications demand more Computations  Computations require Complex Data  Complex Data require Complex organization  Complex Organizations require Complex Processing (Searching, Insertion, Deletion)  Data structures organize data  Provides way of storing data so that it can be used efficiently
  • 7. Selection of Data Structures  The cost of a solution is the amount of resources  The choice of data structure and algorithm can make the difference in execution of a program  Carefully chosen data structure will allow the most effective algorithm to be used  A well-designed data structure allows a variety of critical operations to be performed, using few resources  Quality and performance of the final result depends heavily on choosing the best data structure
  • 8. How to Select a data structure  Analyze the problem to determine the resource constraints a solution must meet  Determine the basic operations that must be supported  Quantify the resource constraints for each operation  Select the data structure that best meets these requirements  Some questions to ask  Amount of data to store  Are all data inserted into the data structure at the beginning, or are insertions interspersed with other operations?  Can data be deleted? If so, a more complex representation is typically required  Are all data processed in some well-defined order, or is random access allowed?
  • 9. Data Structure Philosophy  Each data structure has costs and benefits  Rarely is one data structure better than another in all situations.  A data structure requires:  space for each data item it stores  time to perform each basic operation  programming efforts  Each problem has constraints on available space and time  Only after a careful analysis of problem characteristics can we know the best data structure for the task
  • 10. Methodologies for Analyzing Algorithm  How much of a computer time and memory is utilized by an algorithm  Methodologies  Empirical Comparison (run programs)  Asymptotic Algorithm Analysis  The efficiency analysis concentrates on critical operations:  data interchanges (swaps)  comparisons (<, >, ==, ! =)  arithmetic operations (+, -, =)  Factors affecting running time  Critical resources  Size of the input  Machine load  Operating System, Compiler, …  Problem size
  • 11. Types of Data Structures  Base Data Structures  Primitive  Composite  Linear Data Structures  Array  Linked List  Non-Linear Data Structures  Graph  Tree
  • 12. Arrays  Arrays are the most common data structure used to store collections of elements  Access any element using its index number  Occupies contiguous memory area  Example: int scores[100]; scores[0] = 18; scores[1] = 5; scores[2] = 24; scores 18 5 24 -2134 ... ... ... 14217 Index 0 1 2 3 . . . . . . . 99
  • 13. Pointers  A variable capable of storing an address is called a pointer variable.  Consider the variable declaration: int *ptr;  Such a pointer is said to "point to" an integer.  Storing in ptr the address of an integer variable k is done as ptr = &k;  The "dereferencing operator" refers to the value of that which ptr is pointing to. *ptr = 7;  To print to the screen the integer value stored at the address pointed to by ptr. printf("%dn",*ptr);
  • 14. Structures  We can declare the form of a block of data containing different data types by means of a structure declaration.  For example, struct person { char name[20]; int age; float weight; };  We now declare a variable of type person struct person p;  and access the structure data using this variable as p.age
  • 15. Structures Continued…  We can also declare a pointer to a structure with the declaration: struct person *ptr;  and we point it to our example structure with: st_ptr = &p;  Now, we can access a given member by de-referencing the pointer as (*st_ptr).age = 63;  Or use an alternative syntax as st_ptr->age = 63;