SlideShare a Scribd company logo
1 of 20
Download to read offline
• 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

Introduction to Computer Hardware slides ppt
Introduction to Computer Hardware slides pptIntroduction to Computer Hardware slides ppt
Introduction to Computer Hardware slides pptOsama Yousaf
 
introduction to microprocessor and microcomputer
introduction to microprocessor and microcomputerintroduction to microprocessor and microcomputer
introduction to microprocessor and microcomputerSatya P. Joshi
 
Turing Machine
Turing MachineTuring Machine
Turing MachineRajendran
 
Variables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailVariables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailgourav kottawar
 
Stack organization
Stack organizationStack organization
Stack organizationchauhankapil
 
Input output organisation
Input output organisationInput output organisation
Input output organisationSanjeev Patel
 
External storage devices
External storage devicesExternal storage devices
External storage devicesPankaj Gupta
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer languageSanjeev Patel
 
Memory Organization
Memory OrganizationMemory Organization
Memory OrganizationAcad
 
Data Structure and Algorithms.pptx
Data Structure and Algorithms.pptxData Structure and Algorithms.pptx
Data Structure and Algorithms.pptxSyed Zaid Irshad
 
EE5440 – Computer Architecture - Lecture 2
EE5440 – Computer Architecture - Lecture 2EE5440 – Computer Architecture - Lecture 2
EE5440 – Computer Architecture - Lecture 2Dilawar Khan
 
Functional units of computer
Functional units of computerFunctional units of computer
Functional units of computergaurav jain
 
Addressing mode Computer Architecture
Addressing mode  Computer ArchitectureAddressing mode  Computer Architecture
Addressing mode Computer ArchitectureHaris456
 

What's hot (20)

Introduction to Computer Hardware slides ppt
Introduction to Computer Hardware slides pptIntroduction to Computer Hardware slides ppt
Introduction to Computer Hardware slides ppt
 
introduction to microprocessor and microcomputer
introduction to microprocessor and microcomputerintroduction to microprocessor and microcomputer
introduction to microprocessor and microcomputer
 
Assemblers
AssemblersAssemblers
Assemblers
 
COMPUTER STORAGE
COMPUTER STORAGECOMPUTER STORAGE
COMPUTER STORAGE
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Variables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailVariables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detail
 
Processors
ProcessorsProcessors
Processors
 
ER-Model-ER Diagram
ER-Model-ER DiagramER-Model-ER Diagram
ER-Model-ER Diagram
 
Stack organization
Stack organizationStack organization
Stack organization
 
Computer Organization
Computer OrganizationComputer Organization
Computer Organization
 
Input output organisation
Input output organisationInput output organisation
Input output organisation
 
External storage devices
External storage devicesExternal storage devices
External storage devices
 
Assembler
AssemblerAssembler
Assembler
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer language
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 
Data Structure and Algorithms.pptx
Data Structure and Algorithms.pptxData Structure and Algorithms.pptx
Data Structure and Algorithms.pptx
 
EE5440 – Computer Architecture - Lecture 2
EE5440 – Computer Architecture - Lecture 2EE5440 – Computer Architecture - Lecture 2
EE5440 – Computer Architecture - Lecture 2
 
Functional units of computer
Functional units of computerFunctional units of computer
Functional units of computer
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Addressing mode Computer Architecture
Addressing mode  Computer ArchitectureAddressing mode  Computer Architecture
Addressing mode Computer Architecture
 

Similar to Data structures and algorithms Module-1.pdf

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

Intro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsIntro to Data Structure & Algorithms
Intro to Data Structure & Algorithms
 
Algorithms and Data Structures
Algorithms and Data StructuresAlgorithms and Data Structures
Algorithms and Data Structures
 
Unit 1 abstract data types
Unit 1 abstract data typesUnit 1 abstract data types
Unit 1 abstract data types
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
 
DS M1 full - KQB KtuQbank.pdf
DS M1 full - KQB KtuQbank.pdfDS M1 full - KQB KtuQbank.pdf
DS M1 full - KQB KtuQbank.pdf
 
Cs 331 Data Structures
Cs 331 Data StructuresCs 331 Data Structures
Cs 331 Data Structures
 
U nit i data structure-converted
U nit   i data structure-convertedU nit   i data structure-converted
U nit i data structure-converted
 
Analysis of Algorithms_RR.pptx
Analysis of Algorithms_RR.pptxAnalysis of Algorithms_RR.pptx
Analysis of Algorithms_RR.pptx
 
Lec1.ppt
Lec1.pptLec1.ppt
Lec1.ppt
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.pptx
 
Basic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - NotesBasic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - Notes
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
ADS Introduction
ADS IntroductionADS Introduction
ADS Introduction
 
data structures and its importance
 data structures and its importance  data structures and its importance
data structures and its importance
 
Lecture01.ppt
Lecture01.pptLecture01.ppt
Lecture01.ppt
 

More from DukeCalvin

Computer Science Ethics: Deontological ethics.pptx
Computer Science Ethics: Deontological ethics.pptxComputer Science Ethics: Deontological ethics.pptx
Computer Science Ethics: Deontological ethics.pptxDukeCalvin
 
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 STUDIESDukeCalvin
 
Topic 4 Data Processing.pptx
Topic 4 Data Processing.pptxTopic 4 Data Processing.pptx
Topic 4 Data Processing.pptxDukeCalvin
 
Introduction to IoT.pptx
Introduction to IoT.pptxIntroduction to IoT.pptx
Introduction to IoT.pptxDukeCalvin
 
Data types in Python.pptx
Data types in Python.pptxData types in Python.pptx
Data types in Python.pptxDukeCalvin
 
Python-L1.pptx
Python-L1.pptxPython-L1.pptx
Python-L1.pptxDukeCalvin
 
Entreprenuership skill development.pptx
Entreprenuership skill development.pptxEntreprenuership skill development.pptx
Entreprenuership skill development.pptxDukeCalvin
 

More from DukeCalvin (7)

Computer Science Ethics: Deontological ethics.pptx
Computer Science Ethics: Deontological ethics.pptxComputer Science Ethics: Deontological ethics.pptx
Computer Science Ethics: Deontological ethics.pptx
 
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
 
Topic 4 Data Processing.pptx
Topic 4 Data Processing.pptxTopic 4 Data Processing.pptx
Topic 4 Data Processing.pptx
 
Introduction to IoT.pptx
Introduction to IoT.pptxIntroduction to IoT.pptx
Introduction to IoT.pptx
 
Data types in Python.pptx
Data types in Python.pptxData types in Python.pptx
Data types in Python.pptx
 
Python-L1.pptx
Python-L1.pptxPython-L1.pptx
Python-L1.pptx
 
Entreprenuership skill development.pptx
Entreprenuership skill development.pptxEntreprenuership skill development.pptx
Entreprenuership skill development.pptx
 

Recently uploaded

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 

Recently uploaded (20)

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 

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).