SlideShare a Scribd company logo
1
Introduction to Data
Structures
Lecture 1
Khalid Khankan and Abdisalam Issa-Salwe
Taibah University
College of Computer Science & Engineering
Computer Science Department
2
Outline
1. Choosing Data Structures
2. Selecting Data Structure
3. Data Structure Philosophy
4. Abstract Data Types
5. Logical vs. Physical Form
6. Programs
7. Algorithm Properties
8. References
2
3
Data Structures
A data structure is a scheme
for organizing data in the
memory of a computer.
Some of the more commonly
used data structures include
lists, arrays, stacks, queues,
heaps, trees, and graphs.
Binary Tree
4
Data Structures
The way in which the data is
organized affects the
performance of a program
for different tasks.
Computer programmers
decide which data structures
to use based on the nature
of the data and the
processes that need to be
performed on that data.
Binary Tree
3
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
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.
4
7
Example: A Queue
A queue is an example of commonly used simple data
structure. A queue has beginning and end, called the
front and back of the queue.
Data enters the queue at one end and leaves at the other.
Because of this, data exits the queue in the same order in
which it enters the queue, like people in a checkout line at
a supermarket.
8
Example: A Binary Tree
A binary tree is another
commonly used data
structure. It is organized like
an upside down tree.
Each spot on the tree, called
a node, holds an item of data
along with a left pointer and
a right pointer. Binary Tree
5
9
Example: A Binary Tree
The pointers are lined up
so that the structure forms
the upside down tree, with
a single node at the top,
called the root node, and
branches increasing on the
left and right as you go
down the tree.
Binary Tree
10
Choosing Data Structures
By comparing the queue with
the binary tree, you can see
how the structure of the data
affects what can be done
efficiently with the data.
6
11
Choosing Data Structures
A queue is a good data structure
to use for storing things that need
to be kept in order, such as a set
of documents waiting to be
printed on a network printer.
.
12
Choosing Data Structures
The jobs will be printed in the
order in which they are received.
Most network print servers
maintain such a print queue.
.
7
13
Choosing Data Structures
A binary tree is a good data
structure to use for searching
sorted data.
The middle item from the list is
stored in the root node, with
lesser items to the left and greater
items to the right.
14
Choosing Data Structures
A search begins at the root. The
computer either find the data, or
moves left or right, depending on
the value for which you are
searching.
Each move down the tree cuts the
remaining data in half.
8
15
Choosing Data Structures
Items can be located very quickly
in a tree.
Telephone directory assistance
information is stored in a tree, so
that a name and phone number
can be found quickly.
16
Choosing Data Structures
For some applications, a queue is
the best data structure to use.
For others, a binary tree is better.
Programmers choose from
among many data structures
based on how the data will be
used by the program.
9
17
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.
18
Selecting a Data Structure
Select a data structure as follows:
1. Analyze the problem to determine the resource
constraints a solution must meet.
2. Determine the basic operations that must be
supported. Quantify the resource constraints
for each operation.
3. Select the data structure that best meets these
requirements.
10
19
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 effort.
20
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 effort.
11
21
Abstract Data Types
Abstract Data Type (ADT): a definition for a
data type solely 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.
22
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.
 In a OO language such as C++, an ADT and its
implementation together make up a class.
 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.
12
23
Abstract data types
 we also looked at how to use an array to
model a list
 we call a list an abstract data type
 it has defined operations
 add to the end of the list
 find an item in the list
 delete an item from the list etc.
 it can be implemented in different ways
 array, piece of paper, tree, linked list
 the operations have the same effect no matter how
the list is implemented
 other examples of abstract data types
 set, queue, stack, map
24
Sets
 a set is an unordered
group of elements
 duplicates are not
allowed
 otherwise how would
you tell them apart?
 the set of "foods I
like" contains the
elements
 cereal, chicken, chips,
tomato soup, orange
juice and chocolate
Cereal
Chicken
Chocolate
set of foods I like
Chips
Orange
juice
Tomato
soup
13
25
Lists
 a list is a group of elements
arranged in some order
 so we can talk about
 the first element in the list
 the last element in the list
 element 3
 the order could be meaningful
 alphabetical
 by size
 by time
 or it could simply be the order the
elements were added
 duplicates are allowed
 they are distinguished by their position
Things I ate today
(in chronological order)
1. cereal
2. orange juice
3. chocolate
4. tomato soup
5. chocolate
6. chicken
7. chips
8. chocolate
26
Queue
 a queue is a a group of items arranged in order of arrival
 new items can only be added to the back of the queue
 items can only be removed from the front of the queue
 shoppers at supermarket check-out
 taxis in rank
 computer processes awaiting execution
 first-in, first-out (FIFO)
14
27
Stacks
 a stack is a group of items
arranged in order
 new items can only be
added to the top of the stack
 items can only be removed
from the top of the stack
 stack of chairs or books
 plates in cafeteria
 temporary data storage in
CPU
 last in, first out (LIFO)
28
Maps
 A map is a collection of
key/element pairs
 each element is stored in
a position determined by
its key
 can look up an element
using its key
 also known as a
dictionary
 key is the word
 element is the definition
algorithm
confusion
university
15
29
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.
 In a OO language such as C++, an ADT and its
implementation together make up a class.
 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.
30
Labeling collections of objects
Humans deal with complexity by assigning a
label to an assembly of objects. An ADT
manages complexity through abstraction.
 Hierarchies of labels
Ex1: transistors  gates  CPU.
In a program, implement an ADT, then think only
about the ADT, not its implementation.
16
31
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.
32
Data Type
ADT:
Type
Operations
Data Items:
Logical Form
Data Items:
Physical Form
Data Structure:
Storage Space
Subroutines
17
33
Problems, Algorithms and Programs
 Programmers deal with:
problems,
algorithms and
computer programs.
34
Problems
 Problem: a task to be performed.
Best thought of as inputs and matching
outputs.
Problem definition should include constraints
on the resources that may be consumed by
any acceptable solution.
18
35
Problems (cont)
 Problems  mathematical functions
A function is a matching between inputs (the
domain) and outputs (the range).
An input to a function may be single number,
or a collection of information.
The values making up an input are called the
parameters of the function.
A particular input must always result in the
same output every time the function is
computed.
36
Algorithms and Programs
Algorithm: a method or a process followed to solve
a problem.
 A recipe: The algorithm gives us a “recipe” for solving
the problem by performing a series of steps, where
each step is completely understood and doable.
An algorithm takes the input to a problem
(function) and transforms it to the output.
 A mapping of input to output.
A problem can be solved by many algorithms.
19
37
A problem can have many algorithms
For example, the problem of sorting can be solved
by the following algorithms:
 Insertion sort
 Bubble sort
 Selection sort
 Shell sort
 Merge sort
 Others
38
Algorithm Properties
An algorithm possesses the following properties:
 It must be correct.
 It must be composed of a series of concrete steps.
 There can be no ambiguity as to which step will be performed
next.
 It must be composed of a finite number of steps.
 It must terminate.
A computer program is an instance, or concrete
representation, for an algorithm in some
programming language.
20
39
Programs
 A computer program is a concrete
representation of an algorithm in some
programming language.
 Naturally, there are many programs that
are instances of the same algorithms,
since any modern programming language
can be used to implement any algorithm.
40
References
 Michael Main, Data Structures and Other
Objects Using Java (Third Edition)

More Related Content

What's hot

Stacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti AroraStacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti Arora
kulachihansraj
 
MS Access teaching powerpoint tasks
MS Access teaching powerpoint tasksMS Access teaching powerpoint tasks
MS Access teaching powerpoint tasks
skomadina
 
Data structures
Data structuresData structures
ER MODEL
ER MODELER MODEL
ER MODEL
Rupali Rana
 
Unit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 CompleteUnit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 Complete
Raj vardhan
 
Functional dependencies in Database Management System
Functional dependencies in Database Management SystemFunctional dependencies in Database Management System
Functional dependencies in Database Management System
Kevin Jadiya
 
Database, Lecture-1.ppt
Database, Lecture-1.pptDatabase, Lecture-1.ppt
Database, Lecture-1.ppt
MatshushimaSumaya
 
Data structure power point presentation
Data structure power point presentation Data structure power point presentation
Data structure power point presentation
Anil Kumar Prajapati
 
Understanding operating systems 5th ed ch01
Understanding operating systems 5th ed ch01Understanding operating systems 5th ed ch01
Understanding operating systems 5th ed ch01BarrBoy
 
Type of database models
Type of database modelsType of database models
Type of database models
SanthiNivas
 
FIT-MS-WORD Lab | BCA
FIT-MS-WORD Lab | BCAFIT-MS-WORD Lab | BCA
FIT-MS-WORD Lab | BCA
Raj vardhan
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
DHAAROUN
 
DBMS Multiple Choice Questions
DBMS Multiple Choice QuestionsDBMS Multiple Choice Questions
DBMS Multiple Choice Questions
Shusil Baral
 
File Processing System
File Processing SystemFile Processing System
File Processing System
DMMMSU-SLUC
 
Union in c language
Union  in c languageUnion  in c language
Union in c language
tanmaymodi4
 
Disk management
Disk managementDisk management
Disk management
Agnas Jasmine
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
Arpee Callejo
 
CBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL PresentationCBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL Presentation
Guru Ji
 
Elmasri Navathe DBMS Unit-1 ppt
Elmasri Navathe DBMS Unit-1 pptElmasri Navathe DBMS Unit-1 ppt
Elmasri Navathe DBMS Unit-1 ppt
AbhinavPandey274499
 
stack & queue
stack & queuestack & queue
stack & queue
manju rani
 

What's hot (20)

Stacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti AroraStacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti Arora
 
MS Access teaching powerpoint tasks
MS Access teaching powerpoint tasksMS Access teaching powerpoint tasks
MS Access teaching powerpoint tasks
 
Data structures
Data structuresData structures
Data structures
 
ER MODEL
ER MODELER MODEL
ER MODEL
 
Unit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 CompleteUnit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 Complete
 
Functional dependencies in Database Management System
Functional dependencies in Database Management SystemFunctional dependencies in Database Management System
Functional dependencies in Database Management System
 
Database, Lecture-1.ppt
Database, Lecture-1.pptDatabase, Lecture-1.ppt
Database, Lecture-1.ppt
 
Data structure power point presentation
Data structure power point presentation Data structure power point presentation
Data structure power point presentation
 
Understanding operating systems 5th ed ch01
Understanding operating systems 5th ed ch01Understanding operating systems 5th ed ch01
Understanding operating systems 5th ed ch01
 
Type of database models
Type of database modelsType of database models
Type of database models
 
FIT-MS-WORD Lab | BCA
FIT-MS-WORD Lab | BCAFIT-MS-WORD Lab | BCA
FIT-MS-WORD Lab | BCA
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
DBMS Multiple Choice Questions
DBMS Multiple Choice QuestionsDBMS Multiple Choice Questions
DBMS Multiple Choice Questions
 
File Processing System
File Processing SystemFile Processing System
File Processing System
 
Union in c language
Union  in c languageUnion  in c language
Union in c language
 
Disk management
Disk managementDisk management
Disk management
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 
CBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL PresentationCBSE XII Database Concepts And MySQL Presentation
CBSE XII Database Concepts And MySQL Presentation
 
Elmasri Navathe DBMS Unit-1 ppt
Elmasri Navathe DBMS Unit-1 pptElmasri Navathe DBMS Unit-1 ppt
Elmasri Navathe DBMS Unit-1 ppt
 
stack & queue
stack & queuestack & queue
stack & queue
 

Viewers also liked

Acca 15(software source&selection)
Acca 15(software source&selection)Acca 15(software source&selection)
Lecture1 is322 data&infomanag(introduction)(old curr)
Lecture1 is322 data&infomanag(introduction)(old curr)Lecture1 is322 data&infomanag(introduction)(old curr)
Lecture1 is322 data&infomanag(introduction)(old curr)
Taibah University, College of Computer Science & Engineering
 
Lecture1 is441-(intro toe-commerce)
Lecture1 is441-(intro toe-commerce)Lecture1 is441-(intro toe-commerce)
Lecture6 is353(ea&data viewpoint )
Lecture6 is353(ea&data viewpoint )Lecture6 is353(ea&data viewpoint )
Lecture6 is353(ea&data viewpoint )
Taibah University, College of Computer Science & Engineering
 
Systems for sustainability workshop
Systems for sustainability workshopSystems for sustainability workshop
Systems for sustainability workshop
Andrea Berardi
 
Lecture4 is353-ea(fea)
Lecture4 is353-ea(fea)Lecture4 is353-ea(fea)
Lecture1 is313-(is-innovation&tech)
Lecture1 is313-(is-innovation&tech)Lecture1 is313-(is-innovation&tech)
Lecture1 is313-(is-innovation&tech)
Taibah University, College of Computer Science & Engineering
 
Lecture3 is353-ea(togaf)
Lecture3 is353-ea(togaf)Lecture3 is353-ea(togaf)
Systems Thinking Powerpoint for
Systems Thinking Powerpoint for Systems Thinking Powerpoint for
Systems Thinking Powerpoint for
SERC at Carleton College
 
Designing the Systems Sciences - AHO, Oslo, Oct 2012
Designing the Systems Sciences - AHO, Oslo, Oct 2012 Designing the Systems Sciences - AHO, Oslo, Oct 2012
Designing the Systems Sciences - AHO, Oslo, Oct 2012 Peter Jones
 
Lecture1 is353-enterprise architectureconcept)
Lecture1 is353-enterprise architectureconcept)Lecture1 is353-enterprise architectureconcept)
Lecture1 is353-enterprise architectureconcept)
Taibah University, College of Computer Science & Engineering
 
Designing Futures to Flourish: ISSS 2015 keynote
Designing Futures to Flourish: ISSS 2015 keynoteDesigning Futures to Flourish: ISSS 2015 keynote
Designing Futures to Flourish: ISSS 2015 keynote
Peter Jones
 
ISSS Visual Languages in Systemic Design
ISSS Visual Languages in Systemic DesignISSS Visual Languages in Systemic Design
ISSS Visual Languages in Systemic DesignPeter Jones
 
Systems Thinking workshop @ Lean UX NYC 2014
Systems Thinking workshop @ Lean UX NYC 2014Systems Thinking workshop @ Lean UX NYC 2014
Systems Thinking workshop @ Lean UX NYC 2014
johanna kollmann
 
Soft Systems Methodology: A brief introduction
Soft Systems Methodology: A brief introductionSoft Systems Methodology: A brief introduction
Soft Systems Methodology: A brief introduction
Mario López
 
Lecture2 is353-ea(the zachma framework)
Lecture2 is353-ea(the zachma framework)Lecture2 is353-ea(the zachma framework)
Lecture2 is353-ea(the zachma framework)
Taibah University, College of Computer Science & Engineering
 
Thinking about systems thinking
Thinking about systems thinkingThinking about systems thinking
Thinking about systems thinking
mikeyearworth
 
SoftSystemsMethodology lecture1
SoftSystemsMethodology lecture1SoftSystemsMethodology lecture1

Viewers also liked (20)

Acca 15(software source&selection)
Acca 15(software source&selection)Acca 15(software source&selection)
Acca 15(software source&selection)
 
Lecture1 is322 data&infomanag(introduction)(old curr)
Lecture1 is322 data&infomanag(introduction)(old curr)Lecture1 is322 data&infomanag(introduction)(old curr)
Lecture1 is322 data&infomanag(introduction)(old curr)
 
Lecture1 is441-(intro toe-commerce)
Lecture1 is441-(intro toe-commerce)Lecture1 is441-(intro toe-commerce)
Lecture1 is441-(intro toe-commerce)
 
Lecture6 is353(ea&data viewpoint )
Lecture6 is353(ea&data viewpoint )Lecture6 is353(ea&data viewpoint )
Lecture6 is353(ea&data viewpoint )
 
SoftSystemsMethodology(Lecture2)
SoftSystemsMethodology(Lecture2)SoftSystemsMethodology(Lecture2)
SoftSystemsMethodology(Lecture2)
 
Systems for sustainability workshop
Systems for sustainability workshopSystems for sustainability workshop
Systems for sustainability workshop
 
Lecture4 is353-ea(fea)
Lecture4 is353-ea(fea)Lecture4 is353-ea(fea)
Lecture4 is353-ea(fea)
 
Lecture1 is313-(is-innovation&tech)
Lecture1 is313-(is-innovation&tech)Lecture1 is313-(is-innovation&tech)
Lecture1 is313-(is-innovation&tech)
 
Lecture3 is353-ea(togaf)
Lecture3 is353-ea(togaf)Lecture3 is353-ea(togaf)
Lecture3 is353-ea(togaf)
 
Systems Thinking Powerpoint for
Systems Thinking Powerpoint for Systems Thinking Powerpoint for
Systems Thinking Powerpoint for
 
Designing the Systems Sciences - AHO, Oslo, Oct 2012
Designing the Systems Sciences - AHO, Oslo, Oct 2012 Designing the Systems Sciences - AHO, Oslo, Oct 2012
Designing the Systems Sciences - AHO, Oslo, Oct 2012
 
Lecture1 is353-enterprise architectureconcept)
Lecture1 is353-enterprise architectureconcept)Lecture1 is353-enterprise architectureconcept)
Lecture1 is353-enterprise architectureconcept)
 
Designing Futures to Flourish: ISSS 2015 keynote
Designing Futures to Flourish: ISSS 2015 keynoteDesigning Futures to Flourish: ISSS 2015 keynote
Designing Futures to Flourish: ISSS 2015 keynote
 
ISSS Visual Languages in Systemic Design
ISSS Visual Languages in Systemic DesignISSS Visual Languages in Systemic Design
ISSS Visual Languages in Systemic Design
 
Systems Thinking workshop @ Lean UX NYC 2014
Systems Thinking workshop @ Lean UX NYC 2014Systems Thinking workshop @ Lean UX NYC 2014
Systems Thinking workshop @ Lean UX NYC 2014
 
Soft Systems Methodology: A brief introduction
Soft Systems Methodology: A brief introductionSoft Systems Methodology: A brief introduction
Soft Systems Methodology: A brief introduction
 
Lecture2 is353-ea(the zachma framework)
Lecture2 is353-ea(the zachma framework)Lecture2 is353-ea(the zachma framework)
Lecture2 is353-ea(the zachma framework)
 
Thinking about systems thinking
Thinking about systems thinkingThinking about systems thinking
Thinking about systems thinking
 
Introduction
IntroductionIntroduction
Introduction
 
SoftSystemsMethodology lecture1
SoftSystemsMethodology lecture1SoftSystemsMethodology lecture1
SoftSystemsMethodology lecture1
 

Similar to Lecture1 data structure(introduction)

Ch1
Ch1Ch1
Chapter 1( intro & overview)
Chapter 1( intro & overview)Chapter 1( intro & overview)
Chapter 1( intro & overview)
MUHAMMAD AAMIR
 
UNIT II.docx
UNIT II.docxUNIT II.docx
UNIT II.docx
Revathiparamanathan
 
Datastructures Notes
Datastructures NotesDatastructures Notes
Datastructures Notes
Ranjithkumar C
 
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
Axmedcarb
 
Data structure
Data structureData structure
Data structure
Prof. Dr. K. Adisesha
 
UNIT I - Data Structures.pdf
UNIT I - Data Structures.pdfUNIT I - Data Structures.pdf
UNIT I - Data Structures.pdf
KPRevathiAsstprofITD
 
introduction about data structure_i.pptx
introduction about data structure_i.pptxintroduction about data structure_i.pptx
introduction about data structure_i.pptx
poonamsngr
 
Data structure (basics)
Data structure (basics)Data structure (basics)
Data structure (basics)
ShrushtiGole
 
Data Warehouse ( Dw Of Dwh )
Data Warehouse ( Dw Of Dwh )Data Warehouse ( Dw Of Dwh )
Data Warehouse ( Dw Of Dwh )
Jenny Calhoon
 
1- Introduction.pptx.pdf
1- Introduction.pptx.pdf1- Introduction.pptx.pdf
1- Introduction.pptx.pdf
gm6523
 
DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS
Adams Sidibe
 
Data Structure and its Fundamentals
Data Structure and its FundamentalsData Structure and its Fundamentals
Data Structure and its Fundamentals
Hitesh Mohapatra
 
Lesson 1 - Data Structures and Algorithms Overview.pdf
Lesson 1 - Data Structures and Algorithms Overview.pdfLesson 1 - Data Structures and Algorithms Overview.pdf
Lesson 1 - Data Structures and Algorithms Overview.pdf
LeandroJrErcia
 
Introduction to data structures (ss)
Introduction to data structures (ss)Introduction to data structures (ss)
Introduction to data structures (ss)
Madishetty Prathibha
 
Week 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental ConceptsWeek 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental Concepts
oudesign
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2
RajSingh734307
 

Similar to Lecture1 data structure(introduction) (20)

Lecture1 data structure(introduction)
Lecture1 data structure(introduction)Lecture1 data structure(introduction)
Lecture1 data structure(introduction)
 
Ch1
Ch1Ch1
Ch1
 
Chapter 1( intro & overview)
Chapter 1( intro & overview)Chapter 1( intro & overview)
Chapter 1( intro & overview)
 
Lect 1-2 Zaheer Abbas
Lect 1-2 Zaheer AbbasLect 1-2 Zaheer Abbas
Lect 1-2 Zaheer Abbas
 
UNIT II.docx
UNIT II.docxUNIT II.docx
UNIT II.docx
 
Datastructures Notes
Datastructures NotesDatastructures Notes
Datastructures Notes
 
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
 
Data structure
Data structureData structure
Data structure
 
UNIT I - Data Structures.pdf
UNIT I - Data Structures.pdfUNIT I - Data Structures.pdf
UNIT I - Data Structures.pdf
 
introduction about data structure_i.pptx
introduction about data structure_i.pptxintroduction about data structure_i.pptx
introduction about data structure_i.pptx
 
Data structure (basics)
Data structure (basics)Data structure (basics)
Data structure (basics)
 
Data Warehouse ( Dw Of Dwh )
Data Warehouse ( Dw Of Dwh )Data Warehouse ( Dw Of Dwh )
Data Warehouse ( Dw Of Dwh )
 
1- Introduction.pptx.pdf
1- Introduction.pptx.pdf1- Introduction.pptx.pdf
1- Introduction.pptx.pdf
 
DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS DATA STRUCTURE AND ALGORITHMS
DATA STRUCTURE AND ALGORITHMS
 
Data Structure and its Fundamentals
Data Structure and its FundamentalsData Structure and its Fundamentals
Data Structure and its Fundamentals
 
Lesson 1 - Data Structures and Algorithms Overview.pdf
Lesson 1 - Data Structures and Algorithms Overview.pdfLesson 1 - Data Structures and Algorithms Overview.pdf
Lesson 1 - Data Structures and Algorithms Overview.pdf
 
Lect1.pptx
Lect1.pptxLect1.pptx
Lect1.pptx
 
Introduction to data structures (ss)
Introduction to data structures (ss)Introduction to data structures (ss)
Introduction to data structures (ss)
 
Week 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental ConceptsWeek 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental Concepts
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2
 

More from Taibah University, College of Computer Science & Engineering

Lecture 1- Computer Organization and Architecture.pdf
Lecture 1- Computer Organization and Architecture.pdfLecture 1- Computer Organization and Architecture.pdf
Lecture 1- Computer Organization and Architecture.pdf
Taibah University, College of Computer Science & Engineering
 
The paper the welfare state of the somali nation - a possible solution to t...
The paper   the welfare state of the somali nation - a possible solution to t...The paper   the welfare state of the somali nation - a possible solution to t...
The paper the welfare state of the somali nation - a possible solution to t...
Taibah University, College of Computer Science & Engineering
 
Colonial intrusion and_the_somali_resistance
Colonial intrusion and_the_somali_resistanceColonial intrusion and_the_somali_resistance
Colonial intrusion and_the_somali_resistance
Taibah University, College of Computer Science & Engineering
 
Lecture 3 (Contemporary approaches to Information Systems)
Lecture 3 (Contemporary approaches to Information Systems)Lecture 3 (Contemporary approaches to Information Systems)
Lecture 3 (Contemporary approaches to Information Systems)
Taibah University, College of Computer Science & Engineering
 
Lecture 7 (business-level strategy and the value chain model)
Lecture 7  (business-level strategy and the value chain model)Lecture 7  (business-level strategy and the value chain model)
Lecture 7 (business-level strategy and the value chain model)
Taibah University, College of Computer Science & Engineering
 
Lecture 4 (using information technology for competitive advantage)
Lecture 4 (using information technology for competitive advantage)Lecture 4 (using information technology for competitive advantage)
Lecture 4 (using information technology for competitive advantage)
Taibah University, College of Computer Science & Engineering
 
Lecture 2 (major types of information systems in organizations)
Lecture 2 (major types of information systems in organizations)Lecture 2 (major types of information systems in organizations)
Lecture 2 (major types of information systems in organizations)
Taibah University, College of Computer Science & Engineering
 
Practical session 1 (critical path analaysis)
Practical session 1 (critical path analaysis)Practical session 1 (critical path analaysis)
Practical session 1 (critical path analaysis)
Taibah University, College of Computer Science & Engineering
 
Chapter 2 modeling the process and life-cycle
Chapter 2  modeling the process and life-cycleChapter 2  modeling the process and life-cycle
Chapter 2 modeling the process and life-cycle
Taibah University, College of Computer Science & Engineering
 
Historical Perspective on the Challenge Facing the Somali Sacral Unity
Historical Perspective on the Challenge Facing the Somali Sacral UnityHistorical Perspective on the Challenge Facing the Somali Sacral Unity
Historical Perspective on the Challenge Facing the Somali Sacral Unity
Taibah University, College of Computer Science & Engineering
 
Colonial intrusion and the Somali Resistance
Colonial intrusion and the Somali ResistanceColonial intrusion and the Somali Resistance
Colonial intrusion and the Somali Resistance
Taibah University, College of Computer Science & Engineering
 
Lecture 8 (information systems and strategy planning)
Lecture 8  (information systems and strategy planning)Lecture 8  (information systems and strategy planning)
Lecture 8 (information systems and strategy planning)
Taibah University, College of Computer Science & Engineering
 
Lecture 4 (using information technology for competitive advantage)
Lecture 4 (using information technology for competitive advantage)Lecture 4 (using information technology for competitive advantage)
Lecture 4 (using information technology for competitive advantage)
Taibah University, College of Computer Science & Engineering
 
Lecture2 is331 data&infomanag(databaseenv)
Lecture2 is331 data&infomanag(databaseenv)Lecture2 is331 data&infomanag(databaseenv)
Lecture2 is331 data&infomanag(databaseenv)
Taibah University, College of Computer Science & Engineering
 
Lab 1 (cs351) (computer tech & c++)
Lab 1 (cs351) (computer tech & c++)Lab 1 (cs351) (computer tech & c++)
Lab 1 (cs351) (computer tech & c++)
Taibah University, College of Computer Science & Engineering
 
Is421 lecture01(intro to knowledge management systems)
Is421 lecture01(intro to knowledge management systems)Is421 lecture01(intro to knowledge management systems)
Is421 lecture01(intro to knowledge management systems)
Taibah University, College of Computer Science & Engineering
 
Is 414 lecture 1 (inform centremanag)
Is 414 lecture 1 (inform centremanag)Is 414 lecture 1 (inform centremanag)
Lecture1 (is342) (office automationsystems)
Lecture1  (is342) (office automationsystems)Lecture1  (is342) (office automationsystems)
Lecture1 (is342) (office automationsystems)
Taibah University, College of Computer Science & Engineering
 
Chapter5 is344(gis)(selecting landscape features)
Chapter5 is344(gis)(selecting landscape features)Chapter5 is344(gis)(selecting landscape features)
Chapter5 is344(gis)(selecting landscape features)
Taibah University, College of Computer Science & Engineering
 
Chapter4 is344(gis)(map design)
Chapter4 is344(gis)(map design)Chapter4 is344(gis)(map design)

More from Taibah University, College of Computer Science & Engineering (20)

Lecture 1- Computer Organization and Architecture.pdf
Lecture 1- Computer Organization and Architecture.pdfLecture 1- Computer Organization and Architecture.pdf
Lecture 1- Computer Organization and Architecture.pdf
 
The paper the welfare state of the somali nation - a possible solution to t...
The paper   the welfare state of the somali nation - a possible solution to t...The paper   the welfare state of the somali nation - a possible solution to t...
The paper the welfare state of the somali nation - a possible solution to t...
 
Colonial intrusion and_the_somali_resistance
Colonial intrusion and_the_somali_resistanceColonial intrusion and_the_somali_resistance
Colonial intrusion and_the_somali_resistance
 
Lecture 3 (Contemporary approaches to Information Systems)
Lecture 3 (Contemporary approaches to Information Systems)Lecture 3 (Contemporary approaches to Information Systems)
Lecture 3 (Contemporary approaches to Information Systems)
 
Lecture 7 (business-level strategy and the value chain model)
Lecture 7  (business-level strategy and the value chain model)Lecture 7  (business-level strategy and the value chain model)
Lecture 7 (business-level strategy and the value chain model)
 
Lecture 4 (using information technology for competitive advantage)
Lecture 4 (using information technology for competitive advantage)Lecture 4 (using information technology for competitive advantage)
Lecture 4 (using information technology for competitive advantage)
 
Lecture 2 (major types of information systems in organizations)
Lecture 2 (major types of information systems in organizations)Lecture 2 (major types of information systems in organizations)
Lecture 2 (major types of information systems in organizations)
 
Practical session 1 (critical path analaysis)
Practical session 1 (critical path analaysis)Practical session 1 (critical path analaysis)
Practical session 1 (critical path analaysis)
 
Chapter 2 modeling the process and life-cycle
Chapter 2  modeling the process and life-cycleChapter 2  modeling the process and life-cycle
Chapter 2 modeling the process and life-cycle
 
Historical Perspective on the Challenge Facing the Somali Sacral Unity
Historical Perspective on the Challenge Facing the Somali Sacral UnityHistorical Perspective on the Challenge Facing the Somali Sacral Unity
Historical Perspective on the Challenge Facing the Somali Sacral Unity
 
Colonial intrusion and the Somali Resistance
Colonial intrusion and the Somali ResistanceColonial intrusion and the Somali Resistance
Colonial intrusion and the Somali Resistance
 
Lecture 8 (information systems and strategy planning)
Lecture 8  (information systems and strategy planning)Lecture 8  (information systems and strategy planning)
Lecture 8 (information systems and strategy planning)
 
Lecture 4 (using information technology for competitive advantage)
Lecture 4 (using information technology for competitive advantage)Lecture 4 (using information technology for competitive advantage)
Lecture 4 (using information technology for competitive advantage)
 
Lecture2 is331 data&infomanag(databaseenv)
Lecture2 is331 data&infomanag(databaseenv)Lecture2 is331 data&infomanag(databaseenv)
Lecture2 is331 data&infomanag(databaseenv)
 
Lab 1 (cs351) (computer tech & c++)
Lab 1 (cs351) (computer tech & c++)Lab 1 (cs351) (computer tech & c++)
Lab 1 (cs351) (computer tech & c++)
 
Is421 lecture01(intro to knowledge management systems)
Is421 lecture01(intro to knowledge management systems)Is421 lecture01(intro to knowledge management systems)
Is421 lecture01(intro to knowledge management systems)
 
Is 414 lecture 1 (inform centremanag)
Is 414 lecture 1 (inform centremanag)Is 414 lecture 1 (inform centremanag)
Is 414 lecture 1 (inform centremanag)
 
Lecture1 (is342) (office automationsystems)
Lecture1  (is342) (office automationsystems)Lecture1  (is342) (office automationsystems)
Lecture1 (is342) (office automationsystems)
 
Chapter5 is344(gis)(selecting landscape features)
Chapter5 is344(gis)(selecting landscape features)Chapter5 is344(gis)(selecting landscape features)
Chapter5 is344(gis)(selecting landscape features)
 
Chapter4 is344(gis)(map design)
Chapter4 is344(gis)(map design)Chapter4 is344(gis)(map design)
Chapter4 is344(gis)(map design)
 

Recently uploaded

Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
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
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
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
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 

Recently uploaded (20)

Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
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
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
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
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 

Lecture1 data structure(introduction)

  • 1. 1 Introduction to Data Structures Lecture 1 Khalid Khankan and Abdisalam Issa-Salwe Taibah University College of Computer Science & Engineering Computer Science Department 2 Outline 1. Choosing Data Structures 2. Selecting Data Structure 3. Data Structure Philosophy 4. Abstract Data Types 5. Logical vs. Physical Form 6. Programs 7. Algorithm Properties 8. References
  • 2. 2 3 Data Structures A data structure is a scheme for organizing data in the memory of a computer. Some of the more commonly used data structures include lists, arrays, stacks, queues, heaps, trees, and graphs. Binary Tree 4 Data Structures The way in which the data is organized affects the performance of a program for different tasks. Computer programmers decide which data structures to use based on the nature of the data and the processes that need to be performed on that data. Binary Tree
  • 3. 3 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 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.
  • 4. 4 7 Example: A Queue A queue is an example of commonly used simple data structure. A queue has beginning and end, called the front and back of the queue. Data enters the queue at one end and leaves at the other. Because of this, data exits the queue in the same order in which it enters the queue, like people in a checkout line at a supermarket. 8 Example: A Binary Tree A binary tree is another commonly used data structure. It is organized like an upside down tree. Each spot on the tree, called a node, holds an item of data along with a left pointer and a right pointer. Binary Tree
  • 5. 5 9 Example: A Binary Tree The pointers are lined up so that the structure forms the upside down tree, with a single node at the top, called the root node, and branches increasing on the left and right as you go down the tree. Binary Tree 10 Choosing Data Structures By comparing the queue with the binary tree, you can see how the structure of the data affects what can be done efficiently with the data.
  • 6. 6 11 Choosing Data Structures A queue is a good data structure to use for storing things that need to be kept in order, such as a set of documents waiting to be printed on a network printer. . 12 Choosing Data Structures The jobs will be printed in the order in which they are received. Most network print servers maintain such a print queue. .
  • 7. 7 13 Choosing Data Structures A binary tree is a good data structure to use for searching sorted data. The middle item from the list is stored in the root node, with lesser items to the left and greater items to the right. 14 Choosing Data Structures A search begins at the root. The computer either find the data, or moves left or right, depending on the value for which you are searching. Each move down the tree cuts the remaining data in half.
  • 8. 8 15 Choosing Data Structures Items can be located very quickly in a tree. Telephone directory assistance information is stored in a tree, so that a name and phone number can be found quickly. 16 Choosing Data Structures For some applications, a queue is the best data structure to use. For others, a binary tree is better. Programmers choose from among many data structures based on how the data will be used by the program.
  • 9. 9 17 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. 18 Selecting a Data Structure Select a data structure as follows: 1. Analyze the problem to determine the resource constraints a solution must meet. 2. Determine the basic operations that must be supported. Quantify the resource constraints for each operation. 3. Select the data structure that best meets these requirements.
  • 10. 10 19 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 effort. 20 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 effort.
  • 11. 11 21 Abstract Data Types Abstract Data Type (ADT): a definition for a data type solely 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. 22 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.  In a OO language such as C++, an ADT and its implementation together make up a class.  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.
  • 12. 12 23 Abstract data types  we also looked at how to use an array to model a list  we call a list an abstract data type  it has defined operations  add to the end of the list  find an item in the list  delete an item from the list etc.  it can be implemented in different ways  array, piece of paper, tree, linked list  the operations have the same effect no matter how the list is implemented  other examples of abstract data types  set, queue, stack, map 24 Sets  a set is an unordered group of elements  duplicates are not allowed  otherwise how would you tell them apart?  the set of "foods I like" contains the elements  cereal, chicken, chips, tomato soup, orange juice and chocolate Cereal Chicken Chocolate set of foods I like Chips Orange juice Tomato soup
  • 13. 13 25 Lists  a list is a group of elements arranged in some order  so we can talk about  the first element in the list  the last element in the list  element 3  the order could be meaningful  alphabetical  by size  by time  or it could simply be the order the elements were added  duplicates are allowed  they are distinguished by their position Things I ate today (in chronological order) 1. cereal 2. orange juice 3. chocolate 4. tomato soup 5. chocolate 6. chicken 7. chips 8. chocolate 26 Queue  a queue is a a group of items arranged in order of arrival  new items can only be added to the back of the queue  items can only be removed from the front of the queue  shoppers at supermarket check-out  taxis in rank  computer processes awaiting execution  first-in, first-out (FIFO)
  • 14. 14 27 Stacks  a stack is a group of items arranged in order  new items can only be added to the top of the stack  items can only be removed from the top of the stack  stack of chairs or books  plates in cafeteria  temporary data storage in CPU  last in, first out (LIFO) 28 Maps  A map is a collection of key/element pairs  each element is stored in a position determined by its key  can look up an element using its key  also known as a dictionary  key is the word  element is the definition algorithm confusion university
  • 15. 15 29 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.  In a OO language such as C++, an ADT and its implementation together make up a class.  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. 30 Labeling collections of objects Humans deal with complexity by assigning a label to an assembly of objects. An ADT manages complexity through abstraction.  Hierarchies of labels Ex1: transistors  gates  CPU. In a program, implement an ADT, then think only about the ADT, not its implementation.
  • 16. 16 31 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. 32 Data Type ADT: Type Operations Data Items: Logical Form Data Items: Physical Form Data Structure: Storage Space Subroutines
  • 17. 17 33 Problems, Algorithms and Programs  Programmers deal with: problems, algorithms and computer programs. 34 Problems  Problem: a task to be performed. Best thought of as inputs and matching outputs. Problem definition should include constraints on the resources that may be consumed by any acceptable solution.
  • 18. 18 35 Problems (cont)  Problems  mathematical functions A function is a matching between inputs (the domain) and outputs (the range). An input to a function may be single number, or a collection of information. The values making up an input are called the parameters of the function. A particular input must always result in the same output every time the function is computed. 36 Algorithms and Programs Algorithm: a method or a process followed to solve a problem.  A recipe: The algorithm gives us a “recipe” for solving the problem by performing a series of steps, where each step is completely understood and doable. An algorithm takes the input to a problem (function) and transforms it to the output.  A mapping of input to output. A problem can be solved by many algorithms.
  • 19. 19 37 A problem can have many algorithms For example, the problem of sorting can be solved by the following algorithms:  Insertion sort  Bubble sort  Selection sort  Shell sort  Merge sort  Others 38 Algorithm Properties An algorithm possesses the following properties:  It must be correct.  It must be composed of a series of concrete steps.  There can be no ambiguity as to which step will be performed next.  It must be composed of a finite number of steps.  It must terminate. A computer program is an instance, or concrete representation, for an algorithm in some programming language.
  • 20. 20 39 Programs  A computer program is a concrete representation of an algorithm in some programming language.  Naturally, there are many programs that are instances of the same algorithms, since any modern programming language can be used to implement any algorithm. 40 References  Michael Main, Data Structures and Other Objects Using Java (Third Edition)