SlideShare a Scribd company logo
6
Defining an Algorithm
• an Algorithm follows a certain set of
guidelines and we use the same set of steps to
solve the problem every time we face it.
• The first step of defining an algorithm is to
define the problem that we are trying to solve.
• The algorithm should have a clear problem
statement
• An Algorithm should be correct and efficient.
Most read
8
Characteristics of an Algorithm
• Not all procedures can be called an algorithm. An algorithm should
have the following characteristics −
• Unambiguous − Algorithm should be clear and unambiguous. Each
of its steps (or phases), and their inputs/outputs should be clear
and must lead to only one meaning.
• Input − An algorithm should have 0 or more well-defined inputs.
• Output − An algorithm should have 1 or more well-defined outputs,
and should match the desired output.
• Finiteness − Algorithms must terminate after a finite number of
steps.
• Feasibility − Should be feasible with the available resources.
Most read
14
What is a Data Structure?
• Data Structure is a systematic way to organize
data in order to use it efficiently. Following
terms are the foundation terms of a data
structure.
• any method that's designed to organize
information in an efficient, understandable
way.
Most read
• Course Name: Introduction to Data
Structures and Algorithms
• Course Code: CSM 1232
• Course Level: Year One, Semester
Two
• Credit Unit: 3
Course Objectives
Upon successfully completing this course,
students should be able to:
i. define basic static and dynamic data structures
and relevant standard algorithms for them.
ii. demonstrate advantages and disadvantages of
specific algorithms and data structures.
iii. evaluate algorithms and data structures in terms
of time and memory complexity of basic
operations.
MUNI
UNIVERSITY
T r a n s f o r m i n g L i v e s
INTRODUCTION TO DATA STRUCTURES AND
ALGORITHMS
Chapter 1: The Role of Algorithms in Computing
MUKIMBA FIONA
Main Reference Book.
Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). ​Introduction to algorithms , 3rd
Edition. Cambridge, Mass: MIT Press.
Sub Topics
• Introduction
• Motivation and Definitions
• Algorithms as a technology.
Motivation: What is an Algorithm
• A set of steps or instructions for completing a
task.
Examples
a recipe
Your morning routine
directions to your home
• What is the task in each of the above examples?
• In Computer Science, An algorithm is a set of
steps a program takes to finish a task. ie. Any
correct code is an algorithm.
Defining an Algorithm
• an Algorithm follows a certain set of
guidelines and we use the same set of steps to
solve the problem every time we face it.
• The first step of defining an algorithm is to
define the problem that we are trying to solve.
• The algorithm should have a clear problem
statement
• An Algorithm should be correct and efficient.
Formal definition
• Informally, an algorithm is any well-defined
computational procedure that takes some value,
or set of values, as input and produces some
value, or set of values, as output.
• An algorithm is thus a sequence of computational
steps that transform the input into the output.
We can also view an algorithm as a tool for
solving a well-specified computational problem.
• The statement of the problem specifies in general
terms the desired input/output relationship. The
algorithm describes a specific computational
procedure for achieving that input/output
relationship.
Characteristics of an Algorithm
• Not all procedures can be called an algorithm. An algorithm should
have the following characteristics −
• Unambiguous − Algorithm should be clear and unambiguous. Each
of its steps (or phases), and their inputs/outputs should be clear
and must lead to only one meaning.
• Input − An algorithm should have 0 or more well-defined inputs.
• Output − An algorithm should have 1 or more well-defined outputs,
and should match the desired output.
• Finiteness − Algorithms must terminate after a finite number of
steps.
• Feasibility − Should be feasible with the available resources.
Why you need to understand
Algorithms
• Over time, particular algorithms have been
developed for some problems.
• It is important to know these solutions
• So we don’t repeat
• So we can build on
• So we can know where and when to apply
them
• To understand the solution, you need to
understand the problem well
Understanding the problem
1. Look at the Problem
2. Break it into distinct steps
3. From the distinct steps, identify the best data
structure and the algorithm for the task
• This concept is called algorithmic thinking
Why you need Algorithmic thinking
• Deeper understanding of complexity issues in
programming
• Better sense of how your code will perform in
different contexts
• Ability to look at a task and break it into
smaller sub tasks and then choose the most
efficient strategy for each sub task.
Algorithms as a technology
• Suppose computers were infinitely fast and
computer memory was free.
• Would you have any reason to study
algorithms?
• Why?
• To demonstrate that your solution method
terminates and does so with the correct
answer.
• Algorithms are indeed a technology that keeps
being improved on as more research
discoveries are made.
Algorithms and other technologies
• Consider a travel routing website
• Total system performance depends on
choosing efficient algorithms as much as other
technologies e.g
– advanced computer architectures and fabrication
technologies,
– easy-to-use, intuitive, graphical user interfaces
(GUIs),
– object-oriented systems,
– integrated Web technologies, and
– Fast networking, both wired and wireless.
What is a Data Structure?
• Data Structure is a systematic way to organize
data in order to use it efficiently. Following
terms are the foundation terms of a data
structure.
• any method that's designed to organize
information in an efficient, understandable
way.
Foundation terms of a data structure.
• Interface − Each data structure has an interface.
Interface represents the set of operations that a
data structure supports. An interface only
provides the list of supported operations, type of
parameters they can accept and return type of
these operations.
• Implementation − Implementation provides the
internal representation of a data structure.
Implementation also provides the definition of
the algorithms used in the operations of the data
structure.
Characteristics of a Data Structure
• Correctness − Data structure implementation
should implement its interface correctly.
• Time Complexity − Running time or the
execution time of operations of data structure
must be as small as possible.
• Space Complexity − Memory usage of a data
structure operation should be as little as
possible.
Need for Data Structures
• As applications are getting complex and data rich, there are three
common problems that applications face now-a-days.
• Data Search − Consider an inventory of 1 million(106) items of a
store. If the application is to search an item, it has to search an item
in 1 million(106) items every time slowing down the search. As data
grows, search will become slower.
• Processor speed − Processor speed although being very high, falls
limited if the data grows to billion records.
• Multiple requests − As thousands of users can search data
simultaneously on a web server, even the fast server fails while
searching the data.
To solve the above-mentioned problems, data structures come to
rescue. Data can be organized in a data structure in such a way that all
items may not be required to be searched, and the required data can
be searched almost instantly.
Need for Data Structures- cont
• They allow you to store and manipulate large
amounts of data without running into any
problems.
• Data structures are important because they
determine how efficiently your devices will
function.
• They also indicate whether or not your
program will work correctly
Data Structures - Algorithms Basics
• As already seen, an 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.
• Algorithms are generally created independent of underlying
languages, i.e. an algorithm can be implemented in more than one
programming language.
• From the data structure point of view, following are some
important categories of algorithms −
• Search − Algorithm to search an item in a data structure.
• Sort − Algorithm to sort items in a certain order.
• Insert − Algorithm to insert item in a data structure.
• Update − Algorithm to update an existing item in a data structure.
• Delete − Algorithm to delete an existing item from a data structure.
Execution Time Cases
• There are three cases which are usually used to compare various
data structure's execution time in a relative manner.
• Worst Case − This is the scenario where a particular data structure
operation takes maximum time it can take. If an operation's worst
case time is ƒ(n) then this operation will not take more than ƒ(n)
time where ƒ(n) represents function of n.
• Average Case − This is the scenario depicting the average execution
time of an operation of a data structure. If an operation takes ƒ(n)
time in execution, then m operations will take mƒ(n) time.
• Best Case − This is the scenario depicting the least possible
execution time of an operation of a data structure. If an operation
takes ƒ(n) time in execution, then the actual operation may take
time as the random number which would be maximum as ƒ(n).

More Related Content

What's hot (20)

CS304PC:Computer Organization and Architecture Session 11 general register or...
CS304PC:Computer Organization and Architecture Session 11 general register or...CS304PC:Computer Organization and Architecture Session 11 general register or...
CS304PC:Computer Organization and Architecture Session 11 general register or...
Guru Nanak Technical Institutions
 
Ai 03 solving_problems_by_searching
Ai 03 solving_problems_by_searchingAi 03 solving_problems_by_searching
Ai 03 solving_problems_by_searching
Mohammed Romi
 
Lecture 3 instruction set
Lecture 3  instruction setLecture 3  instruction set
Lecture 3 instruction set
Pradeep Kumar TS
 
Vector Supercomputers and Scientific Array Processors
Vector Supercomputers and Scientific Array ProcessorsVector Supercomputers and Scientific Array Processors
Vector Supercomputers and Scientific Array Processors
Hsuvas Borkakoty
 
Parallel Programming
Parallel ProgrammingParallel Programming
Parallel Programming
Uday Sharma
 
Types of instructions
Types of instructionsTypes of instructions
Types of instructions
ihsanjamil
 
Unit 4 memory system
Unit 4   memory systemUnit 4   memory system
Unit 4 memory system
chidabdu
 
Algorithm Introduction
Algorithm IntroductionAlgorithm Introduction
Algorithm Introduction
Ashim Lamichhane
 
Introduction to Garbage Collection
Introduction to Garbage CollectionIntroduction to Garbage Collection
Introduction to Garbage Collection
Artur Mkrtchyan
 
uninformed search part 1.pptx
uninformed search part 1.pptxuninformed search part 1.pptx
uninformed search part 1.pptx
MUZAMILALI48
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
Rishabh Soni
 
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycleBacktracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
varun arora
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
Principles of programming languages. Detail notes
Principles of programming languages. Detail notesPrinciples of programming languages. Detail notes
Principles of programming languages. Detail notes
VIKAS SINGH BHADOURIA
 
Resource Allocation In Software Project Management
Resource Allocation In Software Project ManagementResource Allocation In Software Project Management
Resource Allocation In Software Project Management
Syed Hassan Ali
 
program flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architectureprogram flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architecture
Pankaj Kumar Jain
 
Rapid Application Development Model
Rapid Application Development ModelRapid Application Development Model
Rapid Application Development Model
Damian T. Gordon
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
Akhil Kaushik
 
Software requirements
Software requirementsSoftware requirements
Software requirements
Dr. Loganathan R
 
Reinforcement learning.pptx
Reinforcement learning.pptxReinforcement learning.pptx
Reinforcement learning.pptx
aniketgupta16440
 
CS304PC:Computer Organization and Architecture Session 11 general register or...
CS304PC:Computer Organization and Architecture Session 11 general register or...CS304PC:Computer Organization and Architecture Session 11 general register or...
CS304PC:Computer Organization and Architecture Session 11 general register or...
Guru Nanak Technical Institutions
 
Ai 03 solving_problems_by_searching
Ai 03 solving_problems_by_searchingAi 03 solving_problems_by_searching
Ai 03 solving_problems_by_searching
Mohammed Romi
 
Vector Supercomputers and Scientific Array Processors
Vector Supercomputers and Scientific Array ProcessorsVector Supercomputers and Scientific Array Processors
Vector Supercomputers and Scientific Array Processors
Hsuvas Borkakoty
 
Parallel Programming
Parallel ProgrammingParallel Programming
Parallel Programming
Uday Sharma
 
Types of instructions
Types of instructionsTypes of instructions
Types of instructions
ihsanjamil
 
Unit 4 memory system
Unit 4   memory systemUnit 4   memory system
Unit 4 memory system
chidabdu
 
Introduction to Garbage Collection
Introduction to Garbage CollectionIntroduction to Garbage Collection
Introduction to Garbage Collection
Artur Mkrtchyan
 
uninformed search part 1.pptx
uninformed search part 1.pptxuninformed search part 1.pptx
uninformed search part 1.pptx
MUZAMILALI48
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
Rishabh Soni
 
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycleBacktracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
Backtracking-N Queens Problem-Graph Coloring-Hamiltonian cycle
varun arora
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
Principles of programming languages. Detail notes
Principles of programming languages. Detail notesPrinciples of programming languages. Detail notes
Principles of programming languages. Detail notes
VIKAS SINGH BHADOURIA
 
Resource Allocation In Software Project Management
Resource Allocation In Software Project ManagementResource Allocation In Software Project Management
Resource Allocation In Software Project Management
Syed Hassan Ali
 
program flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architectureprogram flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architecture
Pankaj Kumar Jain
 
Rapid Application Development Model
Rapid Application Development ModelRapid Application Development Model
Rapid Application Development Model
Damian T. Gordon
 
Reinforcement learning.pptx
Reinforcement learning.pptxReinforcement learning.pptx
Reinforcement learning.pptx
aniketgupta16440
 

Similar to Data structures and algorithms Module-1.pdf (20)

Algorithms and Data Structures
Algorithms and Data StructuresAlgorithms and Data Structures
Algorithms and Data Structures
sonykhan3
 
lecture1-220221114413Algorithims and data structures.pptx
lecture1-220221114413Algorithims and data structures.pptxlecture1-220221114413Algorithims and data structures.pptx
lecture1-220221114413Algorithims and data structures.pptx
smartashammari
 
lecture1-2202211144eeeee24444444413.pptx
lecture1-2202211144eeeee24444444413.pptxlecture1-2202211144eeeee24444444413.pptx
lecture1-2202211144eeeee24444444413.pptx
smartashammari
 
Unit I Data structure and algorithms notes
Unit I Data structure and algorithms notesUnit I Data structure and algorithms notes
Unit I Data structure and algorithms notes
FIONACHATOLA
 
Data Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptxData Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptx
EllenGrace9
 
datastructuresandalgorithm-module1-230307012644-4c895c84.pptx
datastructuresandalgorithm-module1-230307012644-4c895c84.pptxdatastructuresandalgorithm-module1-230307012644-4c895c84.pptx
datastructuresandalgorithm-module1-230307012644-4c895c84.pptx
JobertGrapa1
 
U nit i data structure-converted
U nit   i data structure-convertedU nit   i data structure-converted
U nit i data structure-converted
Shri Shankaracharya College, Bhilai,Junwani
 
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 and algoriythm pres.pptxD
data structure and algoriythm pres.pptxDdata structure and algoriythm pres.pptxD
data structure and algoriythm pres.pptxD
dubaay100
 
DSA - Lesson 1 INtroduction to database.pptx
DSA - Lesson 1 INtroduction to database.pptxDSA - Lesson 1 INtroduction to database.pptx
DSA - Lesson 1 INtroduction to database.pptx
JobertCaeteGrapa
 
DSA - Lesson 1-1Introductio to data struct.pptx
DSA - Lesson 1-1Introductio to data struct.pptxDSA - Lesson 1-1Introductio to data struct.pptx
DSA - Lesson 1-1Introductio to data struct.pptx
JobertCaeteGrapa
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
example43
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
Sumathi MathanMohan
 
Intro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsIntro to Data Structure & Algorithms
Intro to Data Structure & Algorithms
Akhil Kaushik
 
Data Structure Notes unit 1.docx
Data Structure Notes unit 1.docxData Structure Notes unit 1.docx
Data Structure Notes unit 1.docx
kp370932
 
EE-232-LEC-01 Data_structures.pptx
EE-232-LEC-01 Data_structures.pptxEE-232-LEC-01 Data_structures.pptx
EE-232-LEC-01 Data_structures.pptx
iamultapromax
 
Lecture 1 (bce-7)
Lecture   1 (bce-7)Lecture   1 (bce-7)
Lecture 1 (bce-7)
farazahmad005
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
iqbalphy1
 
Chapter 1 Data structure _Algorithms.pptx
Chapter 1 Data structure _Algorithms.pptxChapter 1 Data structure _Algorithms.pptx
Chapter 1 Data structure _Algorithms.pptx
BifaHirpo1
 
Lec1
Lec1Lec1
Lec1
Ibrahim El-Torbany
 
Algorithms and Data Structures
Algorithms and Data StructuresAlgorithms and Data Structures
Algorithms and Data Structures
sonykhan3
 
lecture1-220221114413Algorithims and data structures.pptx
lecture1-220221114413Algorithims and data structures.pptxlecture1-220221114413Algorithims and data structures.pptx
lecture1-220221114413Algorithims and data structures.pptx
smartashammari
 
lecture1-2202211144eeeee24444444413.pptx
lecture1-2202211144eeeee24444444413.pptxlecture1-2202211144eeeee24444444413.pptx
lecture1-2202211144eeeee24444444413.pptx
smartashammari
 
Unit I Data structure and algorithms notes
Unit I Data structure and algorithms notesUnit I Data structure and algorithms notes
Unit I Data structure and algorithms notes
FIONACHATOLA
 
Data Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptxData Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptx
EllenGrace9
 
datastructuresandalgorithm-module1-230307012644-4c895c84.pptx
datastructuresandalgorithm-module1-230307012644-4c895c84.pptxdatastructuresandalgorithm-module1-230307012644-4c895c84.pptx
datastructuresandalgorithm-module1-230307012644-4c895c84.pptx
JobertGrapa1
 
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 and algoriythm pres.pptxD
data structure and algoriythm pres.pptxDdata structure and algoriythm pres.pptxD
data structure and algoriythm pres.pptxD
dubaay100
 
DSA - Lesson 1 INtroduction to database.pptx
DSA - Lesson 1 INtroduction to database.pptxDSA - Lesson 1 INtroduction to database.pptx
DSA - Lesson 1 INtroduction to database.pptx
JobertCaeteGrapa
 
DSA - Lesson 1-1Introductio to data struct.pptx
DSA - Lesson 1-1Introductio to data struct.pptxDSA - Lesson 1-1Introductio to data struct.pptx
DSA - Lesson 1-1Introductio to data struct.pptx
JobertCaeteGrapa
 
Intro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsIntro to Data Structure & Algorithms
Intro to Data Structure & Algorithms
Akhil Kaushik
 
Data Structure Notes unit 1.docx
Data Structure Notes unit 1.docxData Structure Notes unit 1.docx
Data Structure Notes unit 1.docx
kp370932
 
EE-232-LEC-01 Data_structures.pptx
EE-232-LEC-01 Data_structures.pptxEE-232-LEC-01 Data_structures.pptx
EE-232-LEC-01 Data_structures.pptx
iamultapromax
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
iqbalphy1
 
Chapter 1 Data structure _Algorithms.pptx
Chapter 1 Data structure _Algorithms.pptxChapter 1 Data structure _Algorithms.pptx
Chapter 1 Data structure _Algorithms.pptx
BifaHirpo1
 
Ad

More from DukeCalvin (10)

Module 1-History and Overview of Ethical and Legal Issues.pptx
Module 1-History and Overview of Ethical and Legal Issues.pptxModule 1-History and Overview of Ethical and Legal Issues.pptx
Module 1-History and Overview of Ethical and Legal Issues.pptx
DukeCalvin
 
Introduction to the social implications of Computing
Introduction to the social implications of ComputingIntroduction to the social implications of Computing
Introduction to the social implications of Computing
DukeCalvin
 
User Interface DESIGN - A brief summary.pptx
User Interface DESIGN - A brief summary.pptxUser Interface DESIGN - A brief summary.pptx
User Interface DESIGN - A brief summary.pptx
DukeCalvin
 
Computer Science Ethics: Deontological ethics.pptx
Computer Science Ethics: Deontological ethics.pptxComputer Science Ethics: Deontological ethics.pptx
Computer Science Ethics: Deontological ethics.pptx
DukeCalvin
 
COMPUTER SCIENCE: PACIFISM IN ETHICS AND PEACE STUDIES
COMPUTER SCIENCE: PACIFISM IN ETHICS AND PEACE STUDIESCOMPUTER SCIENCE: PACIFISM IN ETHICS AND PEACE STUDIES
COMPUTER SCIENCE: PACIFISM IN ETHICS AND PEACE STUDIES
DukeCalvin
 
Topic 4 Data Processing.pptx
Topic 4 Data Processing.pptxTopic 4 Data Processing.pptx
Topic 4 Data Processing.pptx
DukeCalvin
 
Introduction to IoT.pptx
Introduction to IoT.pptxIntroduction to IoT.pptx
Introduction to IoT.pptx
DukeCalvin
 
Data types in Python.pptx
Data types in Python.pptxData types in Python.pptx
Data types in Python.pptx
DukeCalvin
 
Python-L1.pptx
Python-L1.pptxPython-L1.pptx
Python-L1.pptx
DukeCalvin
 
Entreprenuership skill development.pptx
Entreprenuership skill development.pptxEntreprenuership skill development.pptx
Entreprenuership skill development.pptx
DukeCalvin
 
Module 1-History and Overview of Ethical and Legal Issues.pptx
Module 1-History and Overview of Ethical and Legal Issues.pptxModule 1-History and Overview of Ethical and Legal Issues.pptx
Module 1-History and Overview of Ethical and Legal Issues.pptx
DukeCalvin
 
Introduction to the social implications of Computing
Introduction to the social implications of ComputingIntroduction to the social implications of Computing
Introduction to the social implications of Computing
DukeCalvin
 
User Interface DESIGN - A brief summary.pptx
User Interface DESIGN - A brief summary.pptxUser Interface DESIGN - A brief summary.pptx
User Interface DESIGN - A brief summary.pptx
DukeCalvin
 
Computer Science Ethics: Deontological ethics.pptx
Computer Science Ethics: Deontological ethics.pptxComputer Science Ethics: Deontological ethics.pptx
Computer Science Ethics: Deontological ethics.pptx
DukeCalvin
 
COMPUTER SCIENCE: PACIFISM IN ETHICS AND PEACE STUDIES
COMPUTER SCIENCE: PACIFISM IN ETHICS AND PEACE STUDIESCOMPUTER SCIENCE: PACIFISM IN ETHICS AND PEACE STUDIES
COMPUTER SCIENCE: PACIFISM IN ETHICS AND PEACE STUDIES
DukeCalvin
 
Topic 4 Data Processing.pptx
Topic 4 Data Processing.pptxTopic 4 Data Processing.pptx
Topic 4 Data Processing.pptx
DukeCalvin
 
Introduction to IoT.pptx
Introduction to IoT.pptxIntroduction to IoT.pptx
Introduction to IoT.pptx
DukeCalvin
 
Data types in Python.pptx
Data types in Python.pptxData types in Python.pptx
Data types in Python.pptx
DukeCalvin
 
Python-L1.pptx
Python-L1.pptxPython-L1.pptx
Python-L1.pptx
DukeCalvin
 
Entreprenuership skill development.pptx
Entreprenuership skill development.pptxEntreprenuership skill development.pptx
Entreprenuership skill development.pptx
DukeCalvin
 
Ad

Recently uploaded (20)

Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
Strengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptxStrengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptx
SteffMusniQuiballo
 
LDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad UpdatesLDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad Updates
LDM & Mia eStudios
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
Parenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independenceParenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independence
Pooky Knightsmith
 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
 
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
Strengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptxStrengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptx
SteffMusniQuiballo
 
LDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad UpdatesLDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad Updates
LDM & Mia eStudios
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Optimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptxOptimization technique in pharmaceutical product development.pptx
Optimization technique in pharmaceutical product development.pptx
UrmiPrajapati3
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
Parenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independenceParenting Teens: Supporting Trust, resilience and independence
Parenting Teens: Supporting Trust, resilience and independence
Pooky Knightsmith
 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 

Data structures and algorithms Module-1.pdf

  • 1. • Course Name: Introduction to Data Structures and Algorithms • Course Code: CSM 1232 • Course Level: Year One, Semester Two • Credit Unit: 3
  • 2. Course Objectives Upon successfully completing this course, students should be able to: i. define basic static and dynamic data structures and relevant standard algorithms for them. ii. demonstrate advantages and disadvantages of specific algorithms and data structures. iii. evaluate algorithms and data structures in terms of time and memory complexity of basic operations.
  • 3. MUNI UNIVERSITY T r a n s f o r m i n g L i v e s INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS Chapter 1: The Role of Algorithms in Computing MUKIMBA FIONA Main Reference Book. Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). ​Introduction to algorithms , 3rd Edition. Cambridge, Mass: MIT Press.
  • 4. Sub Topics • Introduction • Motivation and Definitions • Algorithms as a technology.
  • 5. Motivation: What is an Algorithm • A set of steps or instructions for completing a task. Examples a recipe Your morning routine directions to your home • What is the task in each of the above examples? • In Computer Science, An algorithm is a set of steps a program takes to finish a task. ie. Any correct code is an algorithm.
  • 6. Defining an Algorithm • an Algorithm follows a certain set of guidelines and we use the same set of steps to solve the problem every time we face it. • The first step of defining an algorithm is to define the problem that we are trying to solve. • The algorithm should have a clear problem statement • An Algorithm should be correct and efficient.
  • 7. Formal definition • Informally, an algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output. • An algorithm is thus a sequence of computational steps that transform the input into the output. We can also view an algorithm as a tool for solving a well-specified computational problem. • The statement of the problem specifies in general terms the desired input/output relationship. The algorithm describes a specific computational procedure for achieving that input/output relationship.
  • 8. Characteristics of an Algorithm • Not all procedures can be called an algorithm. An algorithm should have the following characteristics − • Unambiguous − Algorithm should be clear and unambiguous. Each of its steps (or phases), and their inputs/outputs should be clear and must lead to only one meaning. • Input − An algorithm should have 0 or more well-defined inputs. • Output − An algorithm should have 1 or more well-defined outputs, and should match the desired output. • Finiteness − Algorithms must terminate after a finite number of steps. • Feasibility − Should be feasible with the available resources.
  • 9. Why you need to understand Algorithms • Over time, particular algorithms have been developed for some problems. • It is important to know these solutions • So we don’t repeat • So we can build on • So we can know where and when to apply them • To understand the solution, you need to understand the problem well
  • 10. Understanding the problem 1. Look at the Problem 2. Break it into distinct steps 3. From the distinct steps, identify the best data structure and the algorithm for the task • This concept is called algorithmic thinking
  • 11. Why you need Algorithmic thinking • Deeper understanding of complexity issues in programming • Better sense of how your code will perform in different contexts • Ability to look at a task and break it into smaller sub tasks and then choose the most efficient strategy for each sub task.
  • 12. Algorithms as a technology • Suppose computers were infinitely fast and computer memory was free. • Would you have any reason to study algorithms? • Why? • To demonstrate that your solution method terminates and does so with the correct answer. • Algorithms are indeed a technology that keeps being improved on as more research discoveries are made.
  • 13. Algorithms and other technologies • Consider a travel routing website • Total system performance depends on choosing efficient algorithms as much as other technologies e.g – advanced computer architectures and fabrication technologies, – easy-to-use, intuitive, graphical user interfaces (GUIs), – object-oriented systems, – integrated Web technologies, and – Fast networking, both wired and wireless.
  • 14. What is a Data Structure? • Data Structure is a systematic way to organize data in order to use it efficiently. Following terms are the foundation terms of a data structure. • any method that's designed to organize information in an efficient, understandable way.
  • 15. Foundation terms of a data structure. • Interface − Each data structure has an interface. Interface represents the set of operations that a data structure supports. An interface only provides the list of supported operations, type of parameters they can accept and return type of these operations. • Implementation − Implementation provides the internal representation of a data structure. Implementation also provides the definition of the algorithms used in the operations of the data structure.
  • 16. Characteristics of a Data Structure • Correctness − Data structure implementation should implement its interface correctly. • Time Complexity − Running time or the execution time of operations of data structure must be as small as possible. • Space Complexity − Memory usage of a data structure operation should be as little as possible.
  • 17. Need for Data Structures • As applications are getting complex and data rich, there are three common problems that applications face now-a-days. • Data Search − Consider an inventory of 1 million(106) items of a store. If the application is to search an item, it has to search an item in 1 million(106) items every time slowing down the search. As data grows, search will become slower. • Processor speed − Processor speed although being very high, falls limited if the data grows to billion records. • Multiple requests − As thousands of users can search data simultaneously on a web server, even the fast server fails while searching the data. To solve the above-mentioned problems, data structures come to rescue. Data can be organized in a data structure in such a way that all items may not be required to be searched, and the required data can be searched almost instantly.
  • 18. Need for Data Structures- cont • They allow you to store and manipulate large amounts of data without running into any problems. • Data structures are important because they determine how efficiently your devices will function. • They also indicate whether or not your program will work correctly
  • 19. Data Structures - Algorithms Basics • As already seen, an 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. • Algorithms are generally created independent of underlying languages, i.e. an algorithm can be implemented in more than one programming language. • From the data structure point of view, following are some important categories of algorithms − • Search − Algorithm to search an item in a data structure. • Sort − Algorithm to sort items in a certain order. • Insert − Algorithm to insert item in a data structure. • Update − Algorithm to update an existing item in a data structure. • Delete − Algorithm to delete an existing item from a data structure.
  • 20. Execution Time Cases • There are three cases which are usually used to compare various data structure's execution time in a relative manner. • Worst Case − This is the scenario where a particular data structure operation takes maximum time it can take. If an operation's worst case time is ƒ(n) then this operation will not take more than ƒ(n) time where ƒ(n) represents function of n. • Average Case − This is the scenario depicting the average execution time of an operation of a data structure. If an operation takes ƒ(n) time in execution, then m operations will take mƒ(n) time. • Best Case − This is the scenario depicting the least possible execution time of an operation of a data structure. If an operation takes ƒ(n) time in execution, then the actual operation may take time as the random number which would be maximum as ƒ(n).