SlideShare a Scribd company logo
Lec#1

Data Structures and
Algorithms
What is a data structure?
Data structures are used to store data in a computer in an

organized fashion.
The scheme of organizing related information that
considers not only the items stored, but also their
relationship to each other .
It is a group of data elements grouped together under one
name.
- These data elements are called members. They can have
different types and different lengths.
- Some of them store the data of same type while others
store different types of data.
In programming the term data structure refers to a scheme
for organizing related piece of information.
 Data Structure = Organized Data + Allowed Operations.
2
Goals of this Course
1. Reinforce the concept that costs and benefits exist

for every data structure.
1. Learn the commonly used data structures.
 These form a programmer's basic data structure

``toolkit.'‘

1. Understand how to measure the cost of a data

structure or program.
 These techniques also allow you to judge the merits

of new data structures that you or others might
invent.
Areas in which data structures are applied
Compiler Design
 Operating System
 Database Management System
 Statistical analysis package
 Numerical Analysis
 Graphics
 Artificial Intelligence

4
The Need for Data Structures
Data structures organize data
⇒ more efficient programs.
More powerful computers
⇒ more complex applications.
More complex applications demand more calculations.
Complex computing tasks are unlike our everyday
experience.
Organizing Data
Any organization for a collection of

records can be searched, processed
in any order, or modified.
The choice of data structure and
algorithm can make the difference
between a program running in a few
seconds or many days.
Efficiency
A solution is said to be efficient if it solves the

problem within its resource constraints.
Space
Time

The cost of a solution is the amount of resources

that the solution consumes.
Selecting a Data Structure
Select a data structure as follows:
1. Analyze the problem to determine the basic
operations that must be supported.
2. Quantify the resource constraints for each
operation.
3. Select the data structure that best meets these
requirements.
Costs and Benefits
Each data structure has costs and benefits.
Rarely is one data structure better than another in all

situations.
Any data structure requires:
space for each data item it stores,
time to perform each basic operation,
programming effort.
Costs and Benefits (cont)
Each problem has constraints on available

space and time.
Only after a careful analysis of problem
characteristics we can know the best data
structure for the task.
Bank example:
Start account: a few minutes
Transactions: a few seconds
Close account: overnight
Example 1.2
Problem: Create a database containing information

about cities and towns.
Tasks: Find by name or attribute or location
Exact match, range query, spatial query
Resource requirements: Times can be from a few
seconds for simple queries to a minute or two for
complex queries
Abstract Data Types
Abstract Data Type (ADT): defining a data type

in terms of a set of values and a set of operations
on that data type.
Each ADT operation is defined by its inputs and

outputs.
Encapsulation: Hide implementation details.
Data Structure
A data structure is the physical implementation of an

ADT.
Each operation associated with the ADT is

implemented by one or more subroutines in the
implementation.

Data structure usually refers to an organization for

data in main memory.
File structure: an organization for data on peripheral

storage, such as a disk drive.
Metaphors
An ADT manages complexity through abstraction:
metaphor.
Hierarchies of labels

Ex: transistors ⇒ gates ⇒ CPU.
In a program, implement an ADT, then think only about
the ADT, not its implementation.
Logical vs. Physical Form
Data items have both a logical and a physical form.
Logical form: definition of the data item within an

ADT.
Ex: Integers in mathematical sense: +, -

Physical form: implementation of the data item within

a data structure.
Ex: 16/32 bit integers, overflow.
Data Type
ADT:
Type
Operations

Data Items:
Logical Form

Data Structure:
Storage Space
Subroutines

Data Items:
Physical Form
Define a linear and non linear data
structure
• Linear data structure: A linear data structure
traverses the data elements sequentially
 Only one data element can directly be reached.
 Ex: Arrays, Linked Lists
• Non-Linear data structure: Every data item is
attached to several other data items in a way that
is specific for reflecting relationships.
• The data items are not arranged in a sequential
structure.
• Ex: Trees, Graphs
17
What are the types of data structures?
The types of data structure are:
Arrays: A set of homogeneous values.
Lists: A group of similar items with
connectivity to the previous or/and next data
items.
Matrix: A way to store data in an organized
form in the form of rows and columns.
Linked list: Stored data in a linear fashion.
Stack: Works in first in last out order. The
element inserted first in stack is removed last
18
Queues: First in First out order. The element

inserted first is removed first.
Records: A set of fields, where each field consists of
data belongs to one data type.
Trees: A data structure where the data is organized
in a hierarchical structure. This type of data structure
follows the sorted order of insertion, deletion and
modification of data items.
Tables: Data is persisted in the form of rows and
columns. These are similar to records, where the
result or manipulation of data is reflected for the
whole table
19

More Related Content

PPTX
Data Structures (CS8391)
Elavarasi K
 
PPT
Abstract data types (adt) intro to data structure part 2
Self-Employed
 
PPTX
Introduction to data structures (ss)
Madishetty Prathibha
 
PPTX
Data structure power point presentation
Anil Kumar Prajapati
 
PPTX
Unit I-Data Structures_Intoduction.pptx
DrkhanchanaR
 
PPTX
Data Structure and Algorithms
iqbalphy1
 
PDF
Querying XML: XPath and XQuery
Katrien Verbert
 
PDF
Operator overloading C++
Lahiru Dilshan
 
Data Structures (CS8391)
Elavarasi K
 
Abstract data types (adt) intro to data structure part 2
Self-Employed
 
Introduction to data structures (ss)
Madishetty Prathibha
 
Data structure power point presentation
Anil Kumar Prajapati
 
Unit I-Data Structures_Intoduction.pptx
DrkhanchanaR
 
Data Structure and Algorithms
iqbalphy1
 
Querying XML: XPath and XQuery
Katrien Verbert
 
Operator overloading C++
Lahiru Dilshan
 

What's hot (20)

PPT
DATA PERSISTENCE IN ANDROID OPERATING SYSTEM
AYESHA JAVED
 
PPTX
Data Structures and Algorithm - Module 1.pptx
EllenGrace9
 
PPTX
sorting and searching.pptx
ParagAhir1
 
PPTX
Chapter-7 Relational Calculus
Kunal Anand
 
PPT
Chapter 1( intro & overview)
MUHAMMAD AAMIR
 
PPTX
Transaction Processing in DBMS.pptx
Lovely Professional University
 
PPT
DATA STRUCTURE AND ALGORITHMS
removed_8057d320f6c8601c14a895598b86eacb
 
PPT
Arrays Basics
Nikhil Pandit
 
PDF
Algorithms Lecture 6: Searching Algorithms
Mohamed Loey
 
PPTX
Java presentation on insertion sort
_fahad_shaikh
 
PDF
Array data structure
maamir farooq
 
PPTX
Array implementation and linked list as datat structure
Tushar Aneyrao
 
PPTX
Arrays in Data Structure and Algorithm
KristinaBorooah
 
PPT
Unit 4 external sorting
DrkhanchanaR
 
PPTX
Memory organization
Dhaval Bagal
 
PPTX
Data Structure and Algorithms
Sumathi MathanMohan
 
PPT
Elementary data organisation
Muzamil Hussain
 
PPTX
Database architecture
VENNILAV6
 
PPTX
Stack Data Structure
Rabin BK
 
PPT
Advanced Operating System- Introduction
Debasis Das
 
DATA PERSISTENCE IN ANDROID OPERATING SYSTEM
AYESHA JAVED
 
Data Structures and Algorithm - Module 1.pptx
EllenGrace9
 
sorting and searching.pptx
ParagAhir1
 
Chapter-7 Relational Calculus
Kunal Anand
 
Chapter 1( intro & overview)
MUHAMMAD AAMIR
 
Transaction Processing in DBMS.pptx
Lovely Professional University
 
DATA STRUCTURE AND ALGORITHMS
removed_8057d320f6c8601c14a895598b86eacb
 
Arrays Basics
Nikhil Pandit
 
Algorithms Lecture 6: Searching Algorithms
Mohamed Loey
 
Java presentation on insertion sort
_fahad_shaikh
 
Array data structure
maamir farooq
 
Array implementation and linked list as datat structure
Tushar Aneyrao
 
Arrays in Data Structure and Algorithm
KristinaBorooah
 
Unit 4 external sorting
DrkhanchanaR
 
Memory organization
Dhaval Bagal
 
Data Structure and Algorithms
Sumathi MathanMohan
 
Elementary data organisation
Muzamil Hussain
 
Database architecture
VENNILAV6
 
Stack Data Structure
Rabin BK
 
Advanced Operating System- Introduction
Debasis Das
 
Ad

Similar to Data Structures & Algorithms (20)

PPT
Lect 1-2 Zaheer Abbas
Information Technology Center
 
PPT
Lect 1-2
Zaheer Aghani
 
PDF
Datastructures Notes
Ranjithkumar C
 
PPTX
INTRODUCTION TO DATA STRUCTURE & ABSTRACT DATA TYPE.pptx
talhaarif554
 
DOCX
UNIT II.docx
Revathiparamanathan
 
PDF
Iare ds lecture_notes_2
RajSingh734307
 
DOC
data structures and algorithm Cha 1and 2.doc
ephremmulu486
 
PDF
UNIT I - Data Structures.pdf
KPRevathiAsstprofITD
 
PPT
Ch1
OmarFarukh3
 
PDF
1- Introduction.pptx.pdf
gm6523
 
PDF
Lesson 1 - Data Structures and Algorithms Overview.pdf
LeandroJrErcia
 
PDF
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Axmedcarb
 
PPTX
Lecture 1. Data Structure & Algorithm.pptx
ArifKamal36
 
PPTX
Chapter 1 Data structure _Algorithms.pptx
BifaHirpo1
 
PDF
Lecture1 data structure(introduction)
Taibah University, College of Computer Science & Engineering
 
PDF
Data structure
Prof. Dr. K. Adisesha
 
PDF
Data Structure and its Fundamentals
Hitesh Mohapatra
 
PPTX
Introduction to data structure
sunilchute1
 
PPTX
Introduction to data structure
sunilchute1
 
PPT
The Stack in Data structure and algorithm
SourajitMaity1
 
Lect 1-2 Zaheer Abbas
Information Technology Center
 
Lect 1-2
Zaheer Aghani
 
Datastructures Notes
Ranjithkumar C
 
INTRODUCTION TO DATA STRUCTURE & ABSTRACT DATA TYPE.pptx
talhaarif554
 
UNIT II.docx
Revathiparamanathan
 
Iare ds lecture_notes_2
RajSingh734307
 
data structures and algorithm Cha 1and 2.doc
ephremmulu486
 
UNIT I - Data Structures.pdf
KPRevathiAsstprofITD
 
1- Introduction.pptx.pdf
gm6523
 
Lesson 1 - Data Structures and Algorithms Overview.pdf
LeandroJrErcia
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Axmedcarb
 
Lecture 1. Data Structure & Algorithm.pptx
ArifKamal36
 
Chapter 1 Data structure _Algorithms.pptx
BifaHirpo1
 
Data structure
Prof. Dr. K. Adisesha
 
Data Structure and its Fundamentals
Hitesh Mohapatra
 
Introduction to data structure
sunilchute1
 
Introduction to data structure
sunilchute1
 
The Stack in Data structure and algorithm
SourajitMaity1
 
Ad

More from Ain-ul-Moiz Khawaja (17)

PPT
Algo>Queues
Ain-ul-Moiz Khawaja
 
PPT
Application of Stacks
Ain-ul-Moiz Khawaja
 
PPT
Algo>Stacks
Ain-ul-Moiz Khawaja
 
PPT
Analysis of Algorithum
Ain-ul-Moiz Khawaja
 
PPT
Algo>ADT list & linked list
Ain-ul-Moiz Khawaja
 
PPT
Algo>Arrays
Ain-ul-Moiz Khawaja
 
PPT
Algo>Abstract data type
Ain-ul-Moiz Khawaja
 
PPT
Algorithum Analysis
Ain-ul-Moiz Khawaja
 
PPT
Sorting algorithums > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
PPT
Sorting algos > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
PPT
Huffman > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
PPT
Graphs > Discrete structures , Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
PPTX
Turn over
Ain-ul-Moiz Khawaja
 
PPTX
Attribution Theories
Ain-ul-Moiz Khawaja
 
PPTX
Attribution Theory
Ain-ul-Moiz Khawaja
 
PPTX
Absenteeism
Ain-ul-Moiz Khawaja
 
PPT
HRM Employee Turnover
Ain-ul-Moiz Khawaja
 
Algo>Queues
Ain-ul-Moiz Khawaja
 
Application of Stacks
Ain-ul-Moiz Khawaja
 
Algo>Stacks
Ain-ul-Moiz Khawaja
 
Analysis of Algorithum
Ain-ul-Moiz Khawaja
 
Algo>ADT list & linked list
Ain-ul-Moiz Khawaja
 
Algo>Arrays
Ain-ul-Moiz Khawaja
 
Algo>Abstract data type
Ain-ul-Moiz Khawaja
 
Algorithum Analysis
Ain-ul-Moiz Khawaja
 
Sorting algorithums > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
Sorting algos > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
Huffman > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
Graphs > Discrete structures , Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
Attribution Theories
Ain-ul-Moiz Khawaja
 
Attribution Theory
Ain-ul-Moiz Khawaja
 
Absenteeism
Ain-ul-Moiz Khawaja
 
HRM Employee Turnover
Ain-ul-Moiz Khawaja
 

Recently uploaded (20)

PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
Sourav Kr Podder
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
PPTX
Understanding operators in c language.pptx
auteharshil95
 
PDF
High Ground Student Revision Booklet Preview
jpinnuck
 
PDF
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
PDF
Landforms and landscapes data surprise preview
jpinnuck
 
PDF
Module 3: Health Systems Tutorial Slides S2 2025
Jonathan Hallett
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PPT
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PDF
Sunset Boulevard Student Revision Booklet
jpinnuck
 
PPTX
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
Strengthening open access through collaboration: building connections with OP...
Jisc
 
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
PPTX
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Open Quiz Monsoon Mind Game Prelims.pptx
Sourav Kr Podder
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
Understanding operators in c language.pptx
auteharshil95
 
High Ground Student Revision Booklet Preview
jpinnuck
 
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
Landforms and landscapes data surprise preview
jpinnuck
 
Module 3: Health Systems Tutorial Slides S2 2025
Jonathan Hallett
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
Sunset Boulevard Student Revision Booklet
jpinnuck
 
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Strengthening open access through collaboration: building connections with OP...
Jisc
 
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 

Data Structures & Algorithms

  • 2. What is a data structure? Data structures are used to store data in a computer in an organized fashion. The scheme of organizing related information that considers not only the items stored, but also their relationship to each other . It is a group of data elements grouped together under one name. - These data elements are called members. They can have different types and different lengths. - Some of them store the data of same type while others store different types of data. In programming the term data structure refers to a scheme for organizing related piece of information.  Data Structure = Organized Data + Allowed Operations. 2
  • 3. Goals of this Course 1. Reinforce the concept that costs and benefits exist for every data structure. 1. Learn the commonly used data structures.  These form a programmer's basic data structure ``toolkit.'‘ 1. Understand how to measure the cost of a data structure or program.  These techniques also allow you to judge the merits of new data structures that you or others might invent.
  • 4. Areas in which data structures are applied Compiler Design  Operating System  Database Management System  Statistical analysis package  Numerical Analysis  Graphics  Artificial Intelligence 4
  • 5. The Need for Data Structures Data structures organize data ⇒ more efficient programs. More powerful computers ⇒ more complex applications. More complex applications demand more calculations. Complex computing tasks are unlike our everyday experience.
  • 6. Organizing Data Any organization for a collection of records can be searched, processed in any order, or modified. The choice of data structure and algorithm can make the difference between a program running in a few seconds or many days.
  • 7. Efficiency A solution is said to be efficient if it solves the problem within its resource constraints. Space Time The cost of a solution is the amount of resources that the solution consumes.
  • 8. Selecting a Data Structure Select a data structure as follows: 1. Analyze the problem to determine the basic operations that must be supported. 2. Quantify the resource constraints for each operation. 3. Select the data structure that best meets these requirements.
  • 9. Costs and Benefits Each data structure has costs and benefits. Rarely is one data structure better than another in all situations. Any data structure requires: space for each data item it stores, time to perform each basic operation, programming effort.
  • 10. Costs and Benefits (cont) Each problem has constraints on available space and time. Only after a careful analysis of problem characteristics we can know the best data structure for the task. Bank example: Start account: a few minutes Transactions: a few seconds Close account: overnight
  • 11. Example 1.2 Problem: Create a database containing information about cities and towns. Tasks: Find by name or attribute or location Exact match, range query, spatial query Resource requirements: Times can be from a few seconds for simple queries to a minute or two for complex queries
  • 12. Abstract Data Types Abstract Data Type (ADT): defining a data type in terms of a set of values and a set of operations on that data type. Each ADT operation is defined by its inputs and outputs. Encapsulation: Hide implementation details.
  • 13. Data Structure A data structure is the physical implementation of an ADT. Each operation associated with the ADT is implemented by one or more subroutines in the implementation. Data structure usually refers to an organization for data in main memory. File structure: an organization for data on peripheral storage, such as a disk drive.
  • 14. Metaphors An ADT manages complexity through abstraction: metaphor. Hierarchies of labels Ex: transistors ⇒ gates ⇒ CPU. In a program, implement an ADT, then think only about the ADT, not its implementation.
  • 15. Logical vs. Physical Form Data items have both a logical and a physical form. Logical form: definition of the data item within an ADT. Ex: Integers in mathematical sense: +, - Physical form: implementation of the data item within a data structure. Ex: 16/32 bit integers, overflow.
  • 16. Data Type ADT: Type Operations Data Items: Logical Form Data Structure: Storage Space Subroutines Data Items: Physical Form
  • 17. Define a linear and non linear data structure • Linear data structure: A linear data structure traverses the data elements sequentially  Only one data element can directly be reached.  Ex: Arrays, Linked Lists • Non-Linear data structure: Every data item is attached to several other data items in a way that is specific for reflecting relationships. • The data items are not arranged in a sequential structure. • Ex: Trees, Graphs 17
  • 18. What are the types of data structures? The types of data structure are: Arrays: A set of homogeneous values. Lists: A group of similar items with connectivity to the previous or/and next data items. Matrix: A way to store data in an organized form in the form of rows and columns. Linked list: Stored data in a linear fashion. Stack: Works in first in last out order. The element inserted first in stack is removed last 18
  • 19. Queues: First in First out order. The element inserted first is removed first. Records: A set of fields, where each field consists of data belongs to one data type. Trees: A data structure where the data is organized in a hierarchical structure. This type of data structure follows the sorted order of insertion, deletion and modification of data items. Tables: Data is persisted in the form of rows and columns. These are similar to records, where the result or manipulation of data is reflected for the whole table 19

Editor's Notes

  • #4: The first goal is a worldview to adopt The second goal is the “nuts and bolts” of the course. The third goal prepares a student for the future.
  • #6: A primary concern for this course is efficiency. You might believe that faster computers make it unnecessary to be concerned with efficiency. However… So we need special training.
  • #7: If you are willing to pay enough in time delay. Example: Simple unordered array of records.
  • #8: Alternate definition: Better than known alternatives (“relatively efficient”). Space and time are typical constraints for programs. This does not mean always strive for the most efficient program. If the program operates well within resource constraints, there is no benefit to making it faster or smaller.
  • #9: Typically want the “simplest” data structure that will meet the requirements.
  • #10: The space required includes data and overhead. Some data structures/algorithms are more complicated than others.
  • #17: In this class, we frequently move above and below “the line” separating logical and physical forms.