SlideShare a Scribd company logo
1 of 28
Rationale
Computer science is a field of study that deals with solving a
variety of problems by using computers.
To solve a given problem by using computers, you need to
design an algorithm for it.
Multiple algorithms can be designed to solve a particular
problem.
An algorithm that provides the maximum efficiency should
be used for solving the problem.
The efficiency of an algorithm can be improved by using an
appropriate data structure.
Data structures help in creating programs that are simple,
reusable, and easy to maintain.
This module will enable a learner to select and implement
an appropriate data structure and algorithm to solve a given
programming problem.
Objectives
In this session, you will learn to:
Explain the role of data structures and algorithms in problem
solving through computers
Identify techniques to design algorithms and measure their
efficiency
Problem solving is an essential part of every scientific
discipline.
Computers are widely being used to solve problems
pertaining to various domains, such as, banking, commerce,
medicine, manufacturing, and transport.
To solve a given problem by using a computer, you need to
write a program for it.
A program consists of two components, algorithm and data
structure.
Role of Algorithms and Data Structures in Problem Solving
Role of Algorithms
The word algorithm is derived from the name of the Persian
mathematician Al Khwarizmi.
An algorithm can be defined as a step-by-step procedure for
solving a problem.
An algorithm helps the user arrive at the correct result in a
finite number of steps.
Role of Algorithms (Contd.)
An algorithm has five important properties:
Finiteness
Definiteness
Input
Output
Effectiveness
Role of Algorithms (Contd.)
A problem can be solved using a computer only if an
algorithm can be written for it.
In addition, algorithms provide the following benefits:
Help in writing the corresponding program
Help in dividing difficult problems into a series of small
solvable problems
Make decision making a more rational process
Help make the process consistent and reliable
Role of Data Structures
Different algorithms can be used to solve the same problem.
Some algorithms may solve the problem more efficiently
than the others.
An algorithm that provides the maximum efficiency should
be used to solve a problem.
One of the basic techniques for improving the efficiency of
algorithms is to use an appropriate data structure.
Data structure is defined as a way of organizing the various
data elements in memory with respect to each other.
Data can be organized in many different ways. Therefore,
you can create as many data structures as you want.
Some data structures that have proved useful over the
years are:
Arrays
Linked Lists
Stacks
Queues
Trees
Graphs
Role of Data Structures (Contd.)
Role of Data Structures (Contd.)
Use of an appropriate data structure, helps improve the
efficiency of a program.
The use of appropriate data structures also allows you to
overcome some other programming challenges, such as:
Simplifying complex problems
Creating standard, reusable code components
Creating programs that are easy to understand and maintain
Data structures can be classified under the following two
categories:
Static: Example – Array
Dynamic: Example – Linked List
Types of Data Structures
An array is a ___________ data structure, and a linked list
is a ____________ data structure.
Just a minute
Answer:
static, dynamic
Two commonly used techniques for designing algorithms
are:
Divide and conquer approach
Greedy approach
Identifying Techniques for Designing Algorithms
Divide and conquer is a powerful approach for solving
conceptually difficult problems.
Divide and conquer approach requires you to find a way of:
Breaking the problem into sub problems
Solving the trivial cases
Combining the solutions to the sub problems to solve the
original problem
Identifying Techniques for Designing Algorithms (Contd.)
Algorithms based on greedy approach are used for solving
optimization problems, where you need to maximize profits
or minimize costs under a given set of conditions.
Some examples of optimization problems are:
Finding the shortest distance from an originating city to a set of
destination cities, given the distances between the pairs of
cities.
Finding the minimum number of currency notes required for an
amount, where an arbitrary number of notes for each
denomination are available.
Selecting items with maximum value from a given set of items,
where the total weight of the selected items cannot exceed a
given value.
Identifying Techniques for Designing Algorithms (Contd.)
The ___________ technique involves selecting the best
available option at each step.
Just a minute
Answer:
Greedy
Recursion:
Refers to the technique of defining a process in terms of itself
Is used to solve complex programming problems that are
repetitive in nature
Is implemented in a program by using a recursive procedure or
function. A recursive procedure or function is a function that
invokes itself
Is useful in writing clear, short, and simple programs
Designing Algorithms Using Recursion
Identify the problem in the following algorithm that attempts
to find the sum of the first n natural numbers:
Algorithm: Sum (n)
1. s = n + Sum(n – 1)
2. Return (s)
Just a minute
Answer:
There is no terminating condition in the given recursive
algorithm. Therefore, it will call itself infinitely. The correct
algorithm would be:
1. If (n = 1)
Return(1)
2. s = n + Sum(n – 1)
3. Return(s)
Factors that affect the efficiency of a program include:
Speed of the machine
Compiler
Operating system
Programming language
Size of the input
In addition to these factors, the way data of a program is
organized, and the algorithm used to solve the problem also
has a significant impact on the efficiency of a program.
Determining the Efficiency of an Algorithm
The efficiency of an algorithm can be computed by
determining the amount of resources it consumes.
The primary resources that an algorithm consumes are:
Time: The CPU time required to execute the algorithm.
Space: The amount of memory used by the algorithm for its
execution.
The lesser resources an algorithm consumes, the more
efficient it is.
Determining the Efficiency of an Algorithm
(Contd.)
Time/Space Tradeoff:
It refers to a situation where you can reduce the use of memory
at the cost of slower program execution, or reduce the running
time at the cost of increased memory usage.
Example is data storage in compressed/uncompressed form.
Memory is extensible, but time is not. Therefore, time
considerations generally override memory considerations.
Time/Space Tradeoff
To measure the time efficiency of an algorithm, you can
write a program based on the algorithm, execute it, and
measure the time it takes to run.
The execution time that you measure in this case would
depend on a number of factors such as:
Speed of the machine
Compiler
Operating system
Programming language
Input data
However, we would like to determine how the execution
time is affected by the nature of the algorithm.
Method for Determining Efficiency
The execution time of an algorithm is directly proportional to
the number of key comparisons involved in the algorithm
and is a function of n, where n is the size of the input data.
The rate at which the running time of an algorithm increases
as a result of an increase in the volume of input data is
called the order of growth of the algorithm.
The order of growth of an algorithm is defined by using the
big O notation.
The big O notation has been accepted as a fundamental
technique for describing the efficiency of an algorithm.
Method for Determining Efficiency (Contd.)
The different orders of growth and their corresponding big O
notations are:
Constant - O(1)
Logarithmic - O(log n)
Linear - O(n)
Loglinear - O(n log n)
Quadratic - O(n
2
)
Cubic - O(n
3
)
Exponential - O(2
n
), O(10
n
)
Method for Determining Efficiency (Contd.)
According to their orders of growth, the big O notations can
be arranged in an increasing order as:
O(1) < O(log n) < O(n) < O(n log n) < O(n
2
) < O(n
3
) < O(2
n
)
< O(10
n
)
Graphs depicting orders of growth for various big O
notations:
Selecting an Efficient Algorithm
Microsoft Word
Document
Problem Statement:
You need to write an algorithm to search for a given word in a
dictionary. Discuss how different algorithms and different ways
of organizing the dictionary data affect the efficiency of the
process.
Group Discussion: Dependence of Efficiency on Selected
Algorithm
In this session, you learned that:
An algorithm can be defined as a step-by-step procedure for
solving a problem that produces the correct result in a finite
number of steps.
An algorithm has five important properties:
Finiteness
Definiteness
Input
Output
Effectiveness
An algorithm that provides the maximum efficiency should be
used for solving the problem.
Summary
Data structures can be classified under the following two
categories:
Static
Dynamic
Two commonly used techniques for designing algorithms are:
Divide and conquer approach
Greedy approach
Recursion refers to a technique of defining a process in terms
of itself. It is used to solve complex programming problems that
are repetitive in nature.
The primary resources that an algorithm consumes are:
Time: The CPU time required to execute the algorithm.
Space: The amount of memory used by the algorithm for
execution.
Summary (Contd.)
Time/space tradeoff refers to a situation where you can reduce
the use of memory at the cost of slower program execution, or
reduce the running time at the cost of increased memory
usage.
The total running time of an algorithm is directly proportional to
the number of comparisons involved in the algorithm.
The order of growth of an algorithm is defined by using the big
O notation.
Summary (Contd.)

More Related Content

What's hot

Ooad lab manual(original)
Ooad lab manual(original)Ooad lab manual(original)
Ooad lab manual(original)dipenpatelpatel
 
SE18_Lec 10_ UML Behaviour and Interaction Diagrams
SE18_Lec 10_ UML Behaviour and Interaction DiagramsSE18_Lec 10_ UML Behaviour and Interaction Diagrams
SE18_Lec 10_ UML Behaviour and Interaction DiagramsAmr E. Mohamed
 
SE18_Lec 08_UML Class Diagram
SE18_Lec 08_UML Class DiagramSE18_Lec 08_UML Class Diagram
SE18_Lec 08_UML Class DiagramAmr E. Mohamed
 
Using Model-Driven Engineering for Decision Support Systems Modelling, Implem...
Using Model-Driven Engineering for Decision Support Systems Modelling, Implem...Using Model-Driven Engineering for Decision Support Systems Modelling, Implem...
Using Model-Driven Engineering for Decision Support Systems Modelling, Implem...CSCJournals
 
CS8592 Object Oriented Analysis & Design - UNIT V
CS8592 Object Oriented Analysis & Design - UNIT V CS8592 Object Oriented Analysis & Design - UNIT V
CS8592 Object Oriented Analysis & Design - UNIT V pkaviya
 
System Models in Software Engineering SE7
System Models in Software Engineering SE7System Models in Software Engineering SE7
System Models in Software Engineering SE7koolkampus
 
Software Engineering Lab Manual
Software Engineering Lab ManualSoftware Engineering Lab Manual
Software Engineering Lab ManualNeelamani Samal
 
Improved learning through remote desktop mirroring control
Improved learning through remote desktop mirroring controlImproved learning through remote desktop mirroring control
Improved learning through remote desktop mirroring controlConference Papers
 
HW/SW Partitioning Approach on Reconfigurable Multimedia System on Chip
HW/SW Partitioning Approach on Reconfigurable Multimedia System on ChipHW/SW Partitioning Approach on Reconfigurable Multimedia System on Chip
HW/SW Partitioning Approach on Reconfigurable Multimedia System on ChipCSCJournals
 
CS8494 SOFTWARE ENGINEERING Unit-3
CS8494 SOFTWARE ENGINEERING Unit-3CS8494 SOFTWARE ENGINEERING Unit-3
CS8494 SOFTWARE ENGINEERING Unit-3SIMONTHOMAS S
 

What's hot (20)

Ooad lab manual(original)
Ooad lab manual(original)Ooad lab manual(original)
Ooad lab manual(original)
 
Ch08
Ch08Ch08
Ch08
 
501 183-191
501 183-191501 183-191
501 183-191
 
Final
FinalFinal
Final
 
SE18_Lec 10_ UML Behaviour and Interaction Diagrams
SE18_Lec 10_ UML Behaviour and Interaction DiagramsSE18_Lec 10_ UML Behaviour and Interaction Diagrams
SE18_Lec 10_ UML Behaviour and Interaction Diagrams
 
TYBSC CS SEM 5 AI NOTES
TYBSC CS SEM 5 AI NOTESTYBSC CS SEM 5 AI NOTES
TYBSC CS SEM 5 AI NOTES
 
SE18_Lec 08_UML Class Diagram
SE18_Lec 08_UML Class DiagramSE18_Lec 08_UML Class Diagram
SE18_Lec 08_UML Class Diagram
 
Using Model-Driven Engineering for Decision Support Systems Modelling, Implem...
Using Model-Driven Engineering for Decision Support Systems Modelling, Implem...Using Model-Driven Engineering for Decision Support Systems Modelling, Implem...
Using Model-Driven Engineering for Decision Support Systems Modelling, Implem...
 
Object oriented analysis and design unit- iii
Object oriented analysis and design unit- iiiObject oriented analysis and design unit- iii
Object oriented analysis and design unit- iii
 
CS8592 Object Oriented Analysis & Design - UNIT V
CS8592 Object Oriented Analysis & Design - UNIT V CS8592 Object Oriented Analysis & Design - UNIT V
CS8592 Object Oriented Analysis & Design - UNIT V
 
50120130405003
5012013040500350120130405003
50120130405003
 
System Models in Software Engineering SE7
System Models in Software Engineering SE7System Models in Software Engineering SE7
System Models in Software Engineering SE7
 
Q P
Q PQ P
Q P
 
Object oriented analysis and design unit- ii
Object oriented analysis and design unit- iiObject oriented analysis and design unit- ii
Object oriented analysis and design unit- ii
 
Software Engineering Lab Manual
Software Engineering Lab ManualSoftware Engineering Lab Manual
Software Engineering Lab Manual
 
Improved learning through remote desktop mirroring control
Improved learning through remote desktop mirroring controlImproved learning through remote desktop mirroring control
Improved learning through remote desktop mirroring control
 
HW/SW Partitioning Approach on Reconfigurable Multimedia System on Chip
HW/SW Partitioning Approach on Reconfigurable Multimedia System on ChipHW/SW Partitioning Approach on Reconfigurable Multimedia System on Chip
HW/SW Partitioning Approach on Reconfigurable Multimedia System on Chip
 
Object oriented analysis and design unit- v
Object oriented analysis and design unit- vObject oriented analysis and design unit- v
Object oriented analysis and design unit- v
 
O1803017981
O1803017981O1803017981
O1803017981
 
CS8494 SOFTWARE ENGINEERING Unit-3
CS8494 SOFTWARE ENGINEERING Unit-3CS8494 SOFTWARE ENGINEERING Unit-3
CS8494 SOFTWARE ENGINEERING Unit-3
 

Viewers also liked

Viewers also liked (11)

A tour around san vicente de la barquera maria
A tour around san vicente de la barquera maria A tour around san vicente de la barquera maria
A tour around san vicente de la barquera maria
 
Mari domingiren etorrera
Mari domingiren etorreraMari domingiren etorrera
Mari domingiren etorrera
 
WCF (Windows Communication Foundation_Unit_01)
WCF (Windows Communication Foundation_Unit_01)WCF (Windows Communication Foundation_Unit_01)
WCF (Windows Communication Foundation_Unit_01)
 
RDBMS_Unit 01
RDBMS_Unit 01RDBMS_Unit 01
RDBMS_Unit 01
 
XML Unit 01
XML Unit 01XML Unit 01
XML Unit 01
 
C programming unit 01
C programming unit 01C programming unit 01
C programming unit 01
 
J2ME Unit_01
J2ME Unit_01J2ME Unit_01
J2ME Unit_01
 
Web Component Development with Servlet and JSP Technologies Unit 01
Web Component Development with Servlet and JSP Technologies Unit 01Web Component Development with Servlet and JSP Technologies Unit 01
Web Component Development with Servlet and JSP Technologies Unit 01
 
Advanced excel unit 01
Advanced excel unit 01Advanced excel unit 01
Advanced excel unit 01
 
WPF (Windows Presentation Foundation Unit 01)
WPF (Windows Presentation Foundation Unit 01)WPF (Windows Presentation Foundation Unit 01)
WPF (Windows Presentation Foundation Unit 01)
 
VB.Net GUI Unit_01
VB.Net GUI Unit_01VB.Net GUI Unit_01
VB.Net GUI Unit_01
 

Similar to Data Structures and Algorithms Unit 01

Chapter 1 Data structure.pptx
Chapter 1 Data structure.pptxChapter 1 Data structure.pptx
Chapter 1 Data structure.pptxwondmhunegn
 
Introduction to Data Structure and algorithm.pptx
Introduction to Data Structure and algorithm.pptxIntroduction to Data Structure and algorithm.pptx
Introduction to Data Structure and algorithm.pptxesuEthopi
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptxSayanSen36
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and AlgorithmDhaval Kaneria
 
Cupdf.com introduction to-data-structures-and-algorithm
Cupdf.com introduction to-data-structures-and-algorithmCupdf.com introduction to-data-structures-and-algorithm
Cupdf.com introduction to-data-structures-and-algorithmTarikuDabala1
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and AlgorithmDhaval Kaneria
 
Data structures & problem solving unit 1 ppt
Data structures & problem solving unit 1 pptData structures & problem solving unit 1 ppt
Data structures & problem solving unit 1 pptaviban
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdfMemMem25
 
AOA Week 01.ppt
AOA Week 01.pptAOA Week 01.ppt
AOA Week 01.pptINAM352782
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure Prof Ansari
 
AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...
AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...
AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...csandit
 
AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...
AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...
AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...cscpconf
 
An approach for software effort estimation using fuzzy numbers and genetic al...
An approach for software effort estimation using fuzzy numbers and genetic al...An approach for software effort estimation using fuzzy numbers and genetic al...
An approach for software effort estimation using fuzzy numbers and genetic al...csandit
 

Similar to Data Structures and Algorithms Unit 01 (20)

Chapter 1 Data structure.pptx
Chapter 1 Data structure.pptxChapter 1 Data structure.pptx
Chapter 1 Data structure.pptx
 
Lec1
Lec1Lec1
Lec1
 
Lec1
Lec1Lec1
Lec1
 
251 - Alogarithms Lects.pdf
251 - Alogarithms Lects.pdf251 - Alogarithms Lects.pdf
251 - Alogarithms Lects.pdf
 
chapter 1
chapter 1chapter 1
chapter 1
 
Lec1
Lec1Lec1
Lec1
 
Introduction to Data Structure and algorithm.pptx
Introduction to Data Structure and algorithm.pptxIntroduction to Data Structure and algorithm.pptx
Introduction to Data Structure and algorithm.pptx
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
 
Lecture 1.pptx
Lecture 1.pptxLecture 1.pptx
Lecture 1.pptx
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
Cupdf.com introduction to-data-structures-and-algorithm
Cupdf.com introduction to-data-structures-and-algorithmCupdf.com introduction to-data-structures-and-algorithm
Cupdf.com introduction to-data-structures-and-algorithm
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
Data structures & problem solving unit 1 ppt
Data structures & problem solving unit 1 pptData structures & problem solving unit 1 ppt
Data structures & problem solving unit 1 ppt
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 
Unit 1 dsa
Unit 1 dsaUnit 1 dsa
Unit 1 dsa
 
AOA Week 01.ppt
AOA Week 01.pptAOA Week 01.ppt
AOA Week 01.ppt
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure
 
AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...
AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...
AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...
 
AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...
AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...
AN APPROACH FOR SOFTWARE EFFORT ESTIMATION USING FUZZY NUMBERS AND GENETIC AL...
 
An approach for software effort estimation using fuzzy numbers and genetic al...
An approach for software effort estimation using fuzzy numbers and genetic al...An approach for software effort estimation using fuzzy numbers and genetic al...
An approach for software effort estimation using fuzzy numbers and genetic al...
 

Recently uploaded

call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
“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
 
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
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
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
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
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
 
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
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 

Recently uploaded (20)

call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
“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...
 
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
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
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
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
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
 
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
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 

Data Structures and Algorithms Unit 01

  • 1. Rationale Computer science is a field of study that deals with solving a variety of problems by using computers. To solve a given problem by using computers, you need to design an algorithm for it. Multiple algorithms can be designed to solve a particular problem. An algorithm that provides the maximum efficiency should be used for solving the problem. The efficiency of an algorithm can be improved by using an appropriate data structure. Data structures help in creating programs that are simple, reusable, and easy to maintain. This module will enable a learner to select and implement an appropriate data structure and algorithm to solve a given programming problem.
  • 2. Objectives In this session, you will learn to: Explain the role of data structures and algorithms in problem solving through computers Identify techniques to design algorithms and measure their efficiency
  • 3. Problem solving is an essential part of every scientific discipline. Computers are widely being used to solve problems pertaining to various domains, such as, banking, commerce, medicine, manufacturing, and transport. To solve a given problem by using a computer, you need to write a program for it. A program consists of two components, algorithm and data structure. Role of Algorithms and Data Structures in Problem Solving
  • 4. Role of Algorithms The word algorithm is derived from the name of the Persian mathematician Al Khwarizmi. An algorithm can be defined as a step-by-step procedure for solving a problem. An algorithm helps the user arrive at the correct result in a finite number of steps.
  • 5. Role of Algorithms (Contd.) An algorithm has five important properties: Finiteness Definiteness Input Output Effectiveness
  • 6. Role of Algorithms (Contd.) A problem can be solved using a computer only if an algorithm can be written for it. In addition, algorithms provide the following benefits: Help in writing the corresponding program Help in dividing difficult problems into a series of small solvable problems Make decision making a more rational process Help make the process consistent and reliable
  • 7. Role of Data Structures Different algorithms can be used to solve the same problem. Some algorithms may solve the problem more efficiently than the others. An algorithm that provides the maximum efficiency should be used to solve a problem. One of the basic techniques for improving the efficiency of algorithms is to use an appropriate data structure. Data structure is defined as a way of organizing the various data elements in memory with respect to each other.
  • 8. Data can be organized in many different ways. Therefore, you can create as many data structures as you want. Some data structures that have proved useful over the years are: Arrays Linked Lists Stacks Queues Trees Graphs Role of Data Structures (Contd.)
  • 9. Role of Data Structures (Contd.) Use of an appropriate data structure, helps improve the efficiency of a program. The use of appropriate data structures also allows you to overcome some other programming challenges, such as: Simplifying complex problems Creating standard, reusable code components Creating programs that are easy to understand and maintain
  • 10. Data structures can be classified under the following two categories: Static: Example – Array Dynamic: Example – Linked List Types of Data Structures
  • 11. An array is a ___________ data structure, and a linked list is a ____________ data structure. Just a minute Answer: static, dynamic
  • 12. Two commonly used techniques for designing algorithms are: Divide and conquer approach Greedy approach Identifying Techniques for Designing Algorithms
  • 13. Divide and conquer is a powerful approach for solving conceptually difficult problems. Divide and conquer approach requires you to find a way of: Breaking the problem into sub problems Solving the trivial cases Combining the solutions to the sub problems to solve the original problem Identifying Techniques for Designing Algorithms (Contd.)
  • 14. Algorithms based on greedy approach are used for solving optimization problems, where you need to maximize profits or minimize costs under a given set of conditions. Some examples of optimization problems are: Finding the shortest distance from an originating city to a set of destination cities, given the distances between the pairs of cities. Finding the minimum number of currency notes required for an amount, where an arbitrary number of notes for each denomination are available. Selecting items with maximum value from a given set of items, where the total weight of the selected items cannot exceed a given value. Identifying Techniques for Designing Algorithms (Contd.)
  • 15. The ___________ technique involves selecting the best available option at each step. Just a minute Answer: Greedy
  • 16. Recursion: Refers to the technique of defining a process in terms of itself Is used to solve complex programming problems that are repetitive in nature Is implemented in a program by using a recursive procedure or function. A recursive procedure or function is a function that invokes itself Is useful in writing clear, short, and simple programs Designing Algorithms Using Recursion
  • 17. Identify the problem in the following algorithm that attempts to find the sum of the first n natural numbers: Algorithm: Sum (n) 1. s = n + Sum(n – 1) 2. Return (s) Just a minute Answer: There is no terminating condition in the given recursive algorithm. Therefore, it will call itself infinitely. The correct algorithm would be: 1. If (n = 1) Return(1) 2. s = n + Sum(n – 1) 3. Return(s)
  • 18. Factors that affect the efficiency of a program include: Speed of the machine Compiler Operating system Programming language Size of the input In addition to these factors, the way data of a program is organized, and the algorithm used to solve the problem also has a significant impact on the efficiency of a program. Determining the Efficiency of an Algorithm
  • 19. The efficiency of an algorithm can be computed by determining the amount of resources it consumes. The primary resources that an algorithm consumes are: Time: The CPU time required to execute the algorithm. Space: The amount of memory used by the algorithm for its execution. The lesser resources an algorithm consumes, the more efficient it is. Determining the Efficiency of an Algorithm (Contd.)
  • 20. Time/Space Tradeoff: It refers to a situation where you can reduce the use of memory at the cost of slower program execution, or reduce the running time at the cost of increased memory usage. Example is data storage in compressed/uncompressed form. Memory is extensible, but time is not. Therefore, time considerations generally override memory considerations. Time/Space Tradeoff
  • 21. To measure the time efficiency of an algorithm, you can write a program based on the algorithm, execute it, and measure the time it takes to run. The execution time that you measure in this case would depend on a number of factors such as: Speed of the machine Compiler Operating system Programming language Input data However, we would like to determine how the execution time is affected by the nature of the algorithm. Method for Determining Efficiency
  • 22. The execution time of an algorithm is directly proportional to the number of key comparisons involved in the algorithm and is a function of n, where n is the size of the input data. The rate at which the running time of an algorithm increases as a result of an increase in the volume of input data is called the order of growth of the algorithm. The order of growth of an algorithm is defined by using the big O notation. The big O notation has been accepted as a fundamental technique for describing the efficiency of an algorithm. Method for Determining Efficiency (Contd.)
  • 23. The different orders of growth and their corresponding big O notations are: Constant - O(1) Logarithmic - O(log n) Linear - O(n) Loglinear - O(n log n) Quadratic - O(n 2 ) Cubic - O(n 3 ) Exponential - O(2 n ), O(10 n ) Method for Determining Efficiency (Contd.)
  • 24. According to their orders of growth, the big O notations can be arranged in an increasing order as: O(1) < O(log n) < O(n) < O(n log n) < O(n 2 ) < O(n 3 ) < O(2 n ) < O(10 n ) Graphs depicting orders of growth for various big O notations: Selecting an Efficient Algorithm Microsoft Word Document
  • 25. Problem Statement: You need to write an algorithm to search for a given word in a dictionary. Discuss how different algorithms and different ways of organizing the dictionary data affect the efficiency of the process. Group Discussion: Dependence of Efficiency on Selected Algorithm
  • 26. In this session, you learned that: An algorithm can be defined as a step-by-step procedure for solving a problem that produces the correct result in a finite number of steps. An algorithm has five important properties: Finiteness Definiteness Input Output Effectiveness An algorithm that provides the maximum efficiency should be used for solving the problem. Summary
  • 27. Data structures can be classified under the following two categories: Static Dynamic Two commonly used techniques for designing algorithms are: Divide and conquer approach Greedy approach Recursion refers to a technique of defining a process in terms of itself. It is used to solve complex programming problems that are repetitive in nature. The primary resources that an algorithm consumes are: Time: The CPU time required to execute the algorithm. Space: The amount of memory used by the algorithm for execution. Summary (Contd.)
  • 28. Time/space tradeoff refers to a situation where you can reduce the use of memory at the cost of slower program execution, or reduce the running time at the cost of increased memory usage. The total running time of an algorithm is directly proportional to the number of comparisons involved in the algorithm. The order of growth of an algorithm is defined by using the big O notation. Summary (Contd.)