SlideShare a Scribd company logo
1 of 20
Unit 1
Introduction to Data
Structure [06 Marks]
Prof. Nita Dongre
Department of Information Technology
MAEER’s MIT Polytechnic, Pune
Course Outcome
CO 1 : Perform basic operations on array.
Unit Outcomes
• Classify different types of data structures based on their characteristics
• Explain complexity of an algorithm in terms of time & space.
• Explain the given operations to be performed on the given type of data
structure.
What will we Learn
• Concept & Need of DS, Abstract Data Types
• Types of Data Structure
• Algorithm Complexity
• Operations on Data Structure
Concept of Data Structure
• Data : Collection of raw facts.
• Data structure is a special way of organizing and storing data in a computer
so that it can be used efficiently.
• Data Structures is about interpretation data elements in terms of some
relationship, for better organization and storage. For example, we have
some data which has, player's name “Sachin" and age 26. Here “Sachin" is
of String data type and 26 is of integer data type.
• We can organize this data as a record like Player record, which will have
both player's name and age. Now we can store player's records in a file or
database as a data structure. For example: "Dhoni" 30, "Gambhir" 31,
"Sachin" 33
Concept of Data Structure
• We can define Data Structure as a set of triplet i.e. D = (D,F,A)
Where
D - Set of Domain (set of data objects)
F - Set of Functions(set of operations performed on data objects)
A - Set of Axioms (set of rules to implement the functions)
• Example :- consider an example of integer data type
D = (0, +/- 1 , +/- 2, …….. )
F = (+,-,*,/)
A = a set of binary arithmetic rules to perform addition, subtraction,
division, multiplication and module operations.
Need of Data Structure
• As applications are getting completed and amount of data is increasing day by day, there
may arise the following problems:
1. Processor speed: To handle very large amout of data, high speed processing is required,
but as the data is growing day by day to the billions of files per entity, processor may fail
to deal with that much amount of data.
2. Data Search: Consider an inventory size of 106 items in a store, If our application needs
to search for a particular item, it needs to traverse 106 items every time, results in
slowing down the search process.
3. Multiple requests: If thousands of users are searching the data simultaneously on a web
server, then there are the chances that a very large server can be failed during that
process
in order to solve the above problems, data structures are used.
Need of Data Structure
1. Data structures are important way of organizing data in a
computer
2. It has a different way of storing and organizing data so that it can
be used efficiently.
3. It helps us to understand relationship of one data element with
other
4. It helps to store a data in logical order.
5. It stores a data that may grow and shrink dynamically over a time
and allows efficient access.
Abstract Data Type
• Abstract Data Type is defined as a mathematical model of data objects that
make up a data type as well as the functions that operate on these objects.
• ADT is the way we look at data structure focusing on what it does and
ignoring how it does it job.
• In ADT only behavior is defined and not implementation.
• Example :- Array,List,Map,set,Stack,Queue,table,Tree,graph etc.
• Real life example:
Book is Abstract (Telephone Book is an implementation)
Types of Data Structure
Primitive Data Structure
 The primitive data structures are the basic data types that are available in most
of the programming languages.
 The primitive data structures are used to represent single values.
 Example: Integer, character, string, Boolean
Non-Primitive Data Structure
 The data structure that are derived from primary data
structure is known as non-Primitive data structure.
 These data types are used to store group of values.
 Example: Arrays, Structure, Union, linked list, Stacks, Queue
etc.
Linear Data Structure
 In linear data structure the elements are stored in sequential order. The linear data structures
are
 Array: Array is a collection of data of same data type stored in consecutive memory
location and is referred by common name
 Linked list: Linked list is a collection of data of same data type but the data items
need not be stored in consecutive memory locations.
 Stack: A stack is a Last-In-First-Out linear data structure in which insertion and
deletion takes place at only one end called the top of the stack.
 Queue: A Queue is a First in First-Out Linear data structure in which insertions takes
place one end called the rear and the deletions takes place at one end called the
Front.
Non-Linear Data Structure
Elements are stored based on the hierarchical relationship among the data. The
following are some of the Non-Linear data structure
Trees:
• Trees are used to represent data that has some hierarchical
relationship among the data elements.
Graph:
• Graph is used to represent data that has relationship between
pair of elements not necessarily hierarchical in nature. For
example electrical and communication networks, airline routes,
flow chart, graphs for planning projects
Algorithm Complexity
• Algorithm is a step-by-step procedure, which defines a set of instructions to be
executed in a certain order to get the desired output.
• Suppose,
X is an algorithm
n is the size of input data
• Then the time and space used by the algorithm X are the two main factors,
which decide the efficiency of X.
1. Time Factor − Time is measured by counting the number of key
operations such as comparisons in the sorting algorithm.
2. Space Factor − Space is measured by counting the maximum memory
space required by the algorithm.
• The complexity of an algorithm f(n) gives the running time and/or the storage
space required by the algorithm in terms of n as the size of input data
Space Complexity
• Space complexity of an algorithm represents the amount of memory space
required by the algorithm in its life cycle.
• The space required by an algorithm is equal to the sum of the following two
components −
1. A fixed part that is a space required to store certain data and
variables, that are independent of the size of the problem.
Example: simple variables and constants used, program size, etc.
2. A variable part is a space required by variables, whose size
depends on the size of the problem.
Example, dynamic memory allocation, recursion stack space, etc.
Space Complexity
• Space complexity S(P) of any algorithm P is written as
S(P) = C + SP(I)
where
C- the fixed part
SP(I) - the variable part of the algorithm, which depends on instance characteristic I.
• Example
Algorithm: Sum(A,B)
Step 1 : start
Step 2 : c= A + B + 10
Step 3 : stop
• Here we have three variables A, B, and C and one constant. Hence S(P) = 1 + 3. Now, space
depends on data types of given variables and constant types and it will be multiplied
accordingly.
.
Time Complexity
• Time complexity of an algorithm represents the amount of time required by
the algorithm to run to completion.
• Time requirements can be defined as a numerical function T(n), where T(n) can
be measured as the number of steps, provided each step consumes constant
time.
• Example
• addition of two n-bit integers takes n steps. Consequently, the total
computational time is T(n) = c ∗ n, where c is the time taken for the addition of
two bits. Here, we observe that T(n) grows linearly as the input size increases.
Operations on Data Structure
• Traversing - Visiting each element of the data structure in order to perform
some specific operation like searching or sorting.
• Insertion - Adding the elements to the data structure at any location.
• Deletion - removing an element from the data structure.
• Searching - finding the location of an element within the data structure.
• Sorting - arranging the data structure in a specific order.
• Merging – Merging of two list to get single list.
Thank You

More Related Content

Similar to Introduction to DS.pptx

Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structuresunilchute1
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structuresunilchute1
 
DS-UNIT 1 FINAL (2).pptx
DS-UNIT 1 FINAL (2).pptxDS-UNIT 1 FINAL (2).pptx
DS-UNIT 1 FINAL (2).pptxprakashvs7
 
Data Structures_Introduction
Data Structures_IntroductionData Structures_Introduction
Data Structures_IntroductionThenmozhiK5
 
Data Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptxData Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptxGIRISHKUMARBC1
 
ds 1 Introduction to Data Structures.ppt
ds 1 Introduction to Data Structures.pptds 1 Introduction to Data Structures.ppt
ds 1 Introduction to Data Structures.pptAlliVinay1
 
II B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptxII B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptxsabithabanu83
 
introduction about data structure_i.pptx
introduction about data structure_i.pptxintroduction about data structure_i.pptx
introduction about data structure_i.pptxpoonamsngr
 
Data structures Basics
Data structures BasicsData structures Basics
Data structures BasicsDurgaDeviCbit
 
Chapter 1( intro & overview)
Chapter 1( intro & overview)Chapter 1( intro & overview)
Chapter 1( intro & overview)MUHAMMAD AAMIR
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfAxmedcarb
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2RajSingh734307
 
1.1 introduction to Data Structures.ppt
1.1 introduction to Data Structures.ppt1.1 introduction to Data Structures.ppt
1.1 introduction to Data Structures.pptAshok280385
 
Data structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfData structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfDukeCalvin
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxShivamKrPathak
 
Introduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searchingIntroduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searchingMvenkatarao
 

Similar to Introduction to DS.pptx (20)

Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
DS-UNIT 1 FINAL (2).pptx
DS-UNIT 1 FINAL (2).pptxDS-UNIT 1 FINAL (2).pptx
DS-UNIT 1 FINAL (2).pptx
 
Data Structures_Introduction
Data Structures_IntroductionData Structures_Introduction
Data Structures_Introduction
 
Data Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptxData Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptx
 
ds 1 Introduction to Data Structures.ppt
ds 1 Introduction to Data Structures.pptds 1 Introduction to Data Structures.ppt
ds 1 Introduction to Data Structures.ppt
 
II B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptxII B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptx
 
introduction about data structure_i.pptx
introduction about data structure_i.pptxintroduction about data structure_i.pptx
introduction about data structure_i.pptx
 
Data structures Basics
Data structures BasicsData structures Basics
Data structures Basics
 
Chapter 1( intro & overview)
Chapter 1( intro & overview)Chapter 1( intro & overview)
Chapter 1( intro & overview)
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2
 
1.1 introduction to Data Structures.ppt
1.1 introduction to Data Structures.ppt1.1 introduction to Data Structures.ppt
1.1 introduction to Data Structures.ppt
 
UNIT I - Data Structures.pdf
UNIT I - Data Structures.pdfUNIT I - Data Structures.pdf
UNIT I - Data Structures.pdf
 
Data structure
Data structureData structure
Data structure
 
dsa.pptx
dsa.pptxdsa.pptx
dsa.pptx
 
Data Structures & Algorithms
Data Structures & AlgorithmsData Structures & Algorithms
Data Structures & Algorithms
 
Data structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfData structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdf
 
DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptx
 
Introduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searchingIntroduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searching
 

Recently uploaded

A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMANIlamathiKannappan
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communicationskarancommunications
 
/:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc...
/:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc.../:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc...
/:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc...lizamodels9
 
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
Tech Startup Growth Hacking 101  - Basics on Growth MarketingTech Startup Growth Hacking 101  - Basics on Growth Marketing
Tech Startup Growth Hacking 101 - Basics on Growth MarketingShawn Pang
 
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...lizamodels9
 
RE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechRE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechNewman George Leech
 
Sales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessSales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessAggregage
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation SlidesKeppelCorporation
 
M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.Aaiza Hassan
 
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,noida100girls
 
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Tina Ji
 
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,noida100girls
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Serviceritikaroy0888
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...Paul Menig
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Neil Kimberley
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageMatteo Carbone
 
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...lizamodels9
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Servicediscovermytutordmt
 

Recently uploaded (20)

A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMAN
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communications
 
/:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc...
/:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc.../:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc...
/:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc...
 
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
Tech Startup Growth Hacking 101  - Basics on Growth MarketingTech Startup Growth Hacking 101  - Basics on Growth Marketing
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
 
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
 
RE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechRE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman Leech
 
Sales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessSales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for Success
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
 
M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.
 
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
 
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
 
Best Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting PartnershipBest Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting Partnership
 
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Service
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
 
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Service
 

Introduction to DS.pptx

  • 1. Unit 1 Introduction to Data Structure [06 Marks] Prof. Nita Dongre Department of Information Technology MAEER’s MIT Polytechnic, Pune
  • 2. Course Outcome CO 1 : Perform basic operations on array.
  • 3. Unit Outcomes • Classify different types of data structures based on their characteristics • Explain complexity of an algorithm in terms of time & space. • Explain the given operations to be performed on the given type of data structure.
  • 4. What will we Learn • Concept & Need of DS, Abstract Data Types • Types of Data Structure • Algorithm Complexity • Operations on Data Structure
  • 5. Concept of Data Structure • Data : Collection of raw facts. • Data structure is a special way of organizing and storing data in a computer so that it can be used efficiently. • Data Structures is about interpretation data elements in terms of some relationship, for better organization and storage. For example, we have some data which has, player's name “Sachin" and age 26. Here “Sachin" is of String data type and 26 is of integer data type. • We can organize this data as a record like Player record, which will have both player's name and age. Now we can store player's records in a file or database as a data structure. For example: "Dhoni" 30, "Gambhir" 31, "Sachin" 33
  • 6. Concept of Data Structure • We can define Data Structure as a set of triplet i.e. D = (D,F,A) Where D - Set of Domain (set of data objects) F - Set of Functions(set of operations performed on data objects) A - Set of Axioms (set of rules to implement the functions) • Example :- consider an example of integer data type D = (0, +/- 1 , +/- 2, …….. ) F = (+,-,*,/) A = a set of binary arithmetic rules to perform addition, subtraction, division, multiplication and module operations.
  • 7. Need of Data Structure • As applications are getting completed and amount of data is increasing day by day, there may arise the following problems: 1. Processor speed: To handle very large amout of data, high speed processing is required, but as the data is growing day by day to the billions of files per entity, processor may fail to deal with that much amount of data. 2. Data Search: Consider an inventory size of 106 items in a store, If our application needs to search for a particular item, it needs to traverse 106 items every time, results in slowing down the search process. 3. Multiple requests: If thousands of users are searching the data simultaneously on a web server, then there are the chances that a very large server can be failed during that process in order to solve the above problems, data structures are used.
  • 8. Need of Data Structure 1. Data structures are important way of organizing data in a computer 2. It has a different way of storing and organizing data so that it can be used efficiently. 3. It helps us to understand relationship of one data element with other 4. It helps to store a data in logical order. 5. It stores a data that may grow and shrink dynamically over a time and allows efficient access.
  • 9. Abstract Data Type • Abstract Data Type is defined as a mathematical model of data objects that make up a data type as well as the functions that operate on these objects. • ADT is the way we look at data structure focusing on what it does and ignoring how it does it job. • In ADT only behavior is defined and not implementation. • Example :- Array,List,Map,set,Stack,Queue,table,Tree,graph etc. • Real life example: Book is Abstract (Telephone Book is an implementation)
  • 10. Types of Data Structure
  • 11. Primitive Data Structure  The primitive data structures are the basic data types that are available in most of the programming languages.  The primitive data structures are used to represent single values.  Example: Integer, character, string, Boolean
  • 12. Non-Primitive Data Structure  The data structure that are derived from primary data structure is known as non-Primitive data structure.  These data types are used to store group of values.  Example: Arrays, Structure, Union, linked list, Stacks, Queue etc.
  • 13. Linear Data Structure  In linear data structure the elements are stored in sequential order. The linear data structures are  Array: Array is a collection of data of same data type stored in consecutive memory location and is referred by common name  Linked list: Linked list is a collection of data of same data type but the data items need not be stored in consecutive memory locations.  Stack: A stack is a Last-In-First-Out linear data structure in which insertion and deletion takes place at only one end called the top of the stack.  Queue: A Queue is a First in First-Out Linear data structure in which insertions takes place one end called the rear and the deletions takes place at one end called the Front.
  • 14. Non-Linear Data Structure Elements are stored based on the hierarchical relationship among the data. The following are some of the Non-Linear data structure Trees: • Trees are used to represent data that has some hierarchical relationship among the data elements. Graph: • Graph is used to represent data that has relationship between pair of elements not necessarily hierarchical in nature. For example electrical and communication networks, airline routes, flow chart, graphs for planning projects
  • 15. Algorithm Complexity • Algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a certain order to get the desired output. • Suppose, X is an algorithm n is the size of input data • Then the time and space used by the algorithm X are the two main factors, which decide the efficiency of X. 1. Time Factor − Time is measured by counting the number of key operations such as comparisons in the sorting algorithm. 2. Space Factor − Space is measured by counting the maximum memory space required by the algorithm. • The complexity of an algorithm f(n) gives the running time and/or the storage space required by the algorithm in terms of n as the size of input data
  • 16. Space Complexity • Space complexity of an algorithm represents the amount of memory space required by the algorithm in its life cycle. • The space required by an algorithm is equal to the sum of the following two components − 1. A fixed part that is a space required to store certain data and variables, that are independent of the size of the problem. Example: simple variables and constants used, program size, etc. 2. A variable part is a space required by variables, whose size depends on the size of the problem. Example, dynamic memory allocation, recursion stack space, etc.
  • 17. Space Complexity • Space complexity S(P) of any algorithm P is written as S(P) = C + SP(I) where C- the fixed part SP(I) - the variable part of the algorithm, which depends on instance characteristic I. • Example Algorithm: Sum(A,B) Step 1 : start Step 2 : c= A + B + 10 Step 3 : stop • Here we have three variables A, B, and C and one constant. Hence S(P) = 1 + 3. Now, space depends on data types of given variables and constant types and it will be multiplied accordingly. .
  • 18. Time Complexity • Time complexity of an algorithm represents the amount of time required by the algorithm to run to completion. • Time requirements can be defined as a numerical function T(n), where T(n) can be measured as the number of steps, provided each step consumes constant time. • Example • addition of two n-bit integers takes n steps. Consequently, the total computational time is T(n) = c ∗ n, where c is the time taken for the addition of two bits. Here, we observe that T(n) grows linearly as the input size increases.
  • 19. Operations on Data Structure • Traversing - Visiting each element of the data structure in order to perform some specific operation like searching or sorting. • Insertion - Adding the elements to the data structure at any location. • Deletion - removing an element from the data structure. • Searching - finding the location of an element within the data structure. • Sorting - arranging the data structure in a specific order. • Merging – Merging of two list to get single list.