SlideShare a Scribd company logo
1 of 15
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 Structurechouguleamruta24
 
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 structureRai 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.pptxGIRISHKUMARBC1
 
Unit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data StructuresresUnit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data Structuresresamplopsurat
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2RajSingh734307
 
Data Structure and its Fundamentals
Data Structure and its FundamentalsData Structure and its Fundamentals
Data Structure and its FundamentalsHitesh Mohapatra
 
1- Introduction.pptx.pdf
1- Introduction.pptx.pdf1- Introduction.pptx.pdf
1- Introduction.pptx.pdfgm6523
 
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.pptxAmrutaNavale2
 
Chapter 1( intro &amp; overview)
Chapter 1( intro &amp; overview)Chapter 1( intro &amp; overview)
Chapter 1( intro &amp; overview)MUHAMMAD AAMIR
 
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).pdNimmi 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

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 

Recently uploaded (20)

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 

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;