SlideShare a Scribd company logo
1 of 21
Design and Analysis of
Algorithm
Week 01
Problem Solving
 Solving problems is the core of computer
science. Programmers must first understand
how a human solves a problem, then
understand how to translate this "algorithm"
into something a computer can do, and
finally how to "write" the specific syntax
(required by a computer) to get the job
done. It is sometimes the case that a
machine will solve a problem in a completely
different way than a human.
Problem Solving
Computer Programmers are problem solvers. In
order to solve a problem on a computer you must:
 Know how to represent the information (data)
describing the problem.
 Determine the steps to transform the
information from one representation into
another.
Problem Solving Process
Algorithm
 An algorithm is a clearly defined set of instructions
to be followed to solve a problem. Algorithms are
generally created independent of underlying
programming languages.
 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. 5
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.
6
Characteristics of an
Algorithm
– Finiteness − Algorithms must terminate
after a finite number of steps.
– Feasibility − Should be feasible with the
available resources.
– Independent − An algorithm should
have step-by-step directions, which should
be independent of any programming code.
Example
 Problem − Design an algorithm to add two
numbers and display the result.
– Step 1 – START
– Step 2 – declare three integers a, b & c
– Step 3 – define values of a & b
– Step 4 – add values of a & b
– Step 5 – store output of Step 4 to c
– Step 6 – print c
– Step 7 – STOP
8
Example
 Problem − Design an algorithm to add two
numbers and display the result.
– Step 1 – START ADD
– Step 2 – get values of a & b
– Step 3 – c  a + b
– Step 4 – display c
– Step 5 – STOP
 Second method is preferable in Data
Structure and Algorithms
9
Algorithm Analysis
 Efficiency of an algorithm can be analyzed at two different
stages, before implementation and after implementation.
They are the following −
– A Priori Analysis − This is a theoretical analysis of an
algorithm. Efficiency of an algorithm is measured by
assuming that all other factors, for example, processor
speed, are constant and have no effect on the
implementation.
– A Posterior Analysis − This is an empirical analysis of
an algorithm. The selected algorithm is implemented
using programming language. This is then executed on
target computer machine. In this analysis, actual
statistics like running time and space required, are
collected 10
Pseudo Code and Algorithm
 An algorithm is a systematic logical approach
used to solve problems in a computer.
 Pseudocode is the statement in plain English
which may be translated later into a programming
language (program).
 Pseudo code is an intermediary between an
algorithm and implemented program
Example
Pseudo code to add two numbers:
 Take two number inputs
 Add numbers using the + operator
 Display the result
Pseudo Code Example
If Ali’s height is greater then 6 feet
Then
Ali can become a member of the Basket Ball
team
Conversion from Pseudo code to
Source code
Pseudo Code
If amir’s age is greater than Ammara’s age
then show message that amir is elder than
amara, otherwise show message that amir
is younger than ammara.
Conversion from Pseudo code
to Source code
Source Code
if (AmirAge > AmaraAge)
{
cout<< “Amir is older than Amara” ;
}
else
{
cout<<“Amir is younger than or of the same
age as Amara” ;
}
Algorithm : Find the largest number among three numbers
 Step 1: Start
 Step 2: Declare variables a,b and c.
 Step 3: Read variables a,b and c.
 Step 4: If a > b
 If a > c
 Display a is the largest number.
 Else
 Display c is the largest number.
 Else
 If b > c
 Display b is the largest number.
 Else
 Display c is the greatest number.
 Step 5: Stop
Algorithm: Find the factorial of a
number
 Step 1: Start
 Step 2: Declare variables n, factorial and i.
 Step 3: Initialize variables
 factorial ← 1
 i ← 1
 Step 4: Read value of n
 Step 5: Repeat the steps until i = n
 5.1: factorial ← factorial*i
 5.2: i ← i+1
 Step 6: Display factorial
 Step 7: Stop
Sorting Problem
 we might need to sort a sequence of numbers into non
decreasing order. This problem arises frequently in practice
and provides fertile ground for introducing many standard
design techniques and analysis tools. Here is how we
formally define the sorting problem:
 Input: A sequence of n numbers (a1, a2,……an).
Sorting Problem
 For example, given the input sequence (31; 41; 59; 26; 41; 58) a
sorting algorithm returns as output the sequence (26; 31; 41; 41; 58;
59). Such an input sequence is called an instance of the sorting
problem. In general, an instance of a problem consists of the input
(satisfying whatever constraints are imposed in the problem
statement) needed to compute a solution to the problem.
 Because many programs use it as an intermediate step, sorting is a
fundamental operation in computer science. As a result, we have a
large number of good sorting algorithms at our disposal. Which
algorithm is best for a given application depends on—among other
factors—the number of items to be sorted, the extent to which the
items are already somewhat sorted, possible restrictions on the item
values, the architecture of the computer, and the kind of storage
devices to be used: main memory, disks, or even tapes.
What kinds of problems are solved by
algorithms?
 The Human Genome Project has made great progress toward the goals
of identifying all the 100,000 genes in human DNA, determining the
sequences of the 3 billion chemical base pairs that make up human
DNA, storing this information in databases, and developing tools for
data analysis. Each of these steps requires sophisticated algorithms.
 The Internet enables people all around the world to quickly access and
retrieve large amounts of information. With the aid of clever algorithms,
sites on the internet are able to manage and manipulate this large
volume of data. Examples of problems that make essential use of
algorithms include finding good routes.
 Electronic commerce enables goods and services to be negotiated and
exchanged electronically, and it depends on the privacy of personal
information such as credit card numbers, passwords, and bank
statements. The core technologies used in electronic commerce include
public-key cryptography and digital signatures which are based on
numerical algorithms and number theory.
What kinds of problems are solved by
algorithms?
 Manufacturing and other commercial enterprises often need to
allocate scarce resources in the most beneficial way.
 An oil company may wish to know where to place its wells in
order to maximize its expected profit.
 A political candidate may want to determine where to spend
money buying campaign advertising in order to maximize the
chances of winning an election.
 An airline may wish to assign crews to flights in the least
expensive way possible, making sure that each flight is covered
and that government regulations regarding crew scheduling are
met.
 An Internet service provider may wish to determine where to
place additional resources in order to serve its customers more
effectively. All of these are examples of problems that can be
solved using linear programming algos.

More Related Content

Similar to AOA Week 01.ppt

Program concep sequential statements
Program concep sequential statementsProgram concep sequential statements
Program concep sequential statementsankurkhanna
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)praveena p
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptxssuser586772
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartSachin Goyani
 
Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01Prashanth Shivakumar
 
Algorithm types performance steps working
Algorithm types performance steps workingAlgorithm types performance steps working
Algorithm types performance steps workingSaurabh846965
 
Algorithms notes 2 tutorials duniya
Algorithms notes 2   tutorials duniyaAlgorithms notes 2   tutorials duniya
Algorithms notes 2 tutorials duniyaTutorialsDuniya.com
 
11 Unit 1 Problem Solving Techniques
11  Unit 1 Problem Solving Techniques11  Unit 1 Problem Solving Techniques
11 Unit 1 Problem Solving TechniquesPraveen M Jigajinni
 
c_algo_flowchart.pdf
c_algo_flowchart.pdfc_algo_flowchart.pdf
c_algo_flowchart.pdfsimmis5
 
Lecture 01-2.ppt
Lecture 01-2.pptLecture 01-2.ppt
Lecture 01-2.pptRaoHamza24
 
CP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and AlgorithmsCP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and AlgorithmsSheba41
 
Software develop....
Software develop.... Software develop....
Software develop.... GCWUS
 
GE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdfGE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdfAsst.prof M.Gokilavani
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow chartsPraveen M Jigajinni
 

Similar to AOA Week 01.ppt (20)

Program concep sequential statements
Program concep sequential statementsProgram concep sequential statements
Program concep sequential statements
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01Data Structures and Algorithms Unit 01
Data Structures and Algorithms Unit 01
 
Algorithm types performance steps working
Algorithm types performance steps workingAlgorithm types performance steps working
Algorithm types performance steps working
 
Algorithms notes 2 tutorials duniya
Algorithms notes 2   tutorials duniyaAlgorithms notes 2   tutorials duniya
Algorithms notes 2 tutorials duniya
 
Practical 01 (detailed)
Practical 01 (detailed)Practical 01 (detailed)
Practical 01 (detailed)
 
Algo and flowchart
Algo and flowchartAlgo and flowchart
Algo and flowchart
 
11 Unit 1 Problem Solving Techniques
11  Unit 1 Problem Solving Techniques11  Unit 1 Problem Solving Techniques
11 Unit 1 Problem Solving Techniques
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
 
c_algo_flowchart.pdf
c_algo_flowchart.pdfc_algo_flowchart.pdf
c_algo_flowchart.pdf
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Lecture 01-2.ppt
Lecture 01-2.pptLecture 01-2.ppt
Lecture 01-2.ppt
 
ALGO.ppt
ALGO.pptALGO.ppt
ALGO.ppt
 
CP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and AlgorithmsCP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and Algorithms
 
Software develop....
Software develop.... Software develop....
Software develop....
 
GE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdfGE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdf
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow charts
 
phases of algorithm
phases of algorithmphases of algorithm
phases of algorithm
 

Recently uploaded

Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...babafaisel
 
Chapter 19_DDA_TOD Policy_First Draft 2012.pdf
Chapter 19_DDA_TOD Policy_First Draft 2012.pdfChapter 19_DDA_TOD Policy_First Draft 2012.pdf
Chapter 19_DDA_TOD Policy_First Draft 2012.pdfParomita Roy
 
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceanilsa9823
 
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...Call Girls in Nagpur High Profile
 
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130Suhani Kapoor
 
VIP Russian Call Girls in Saharanpur Deepika 8250192130 Independent Escort Se...
VIP Russian Call Girls in Saharanpur Deepika 8250192130 Independent Escort Se...VIP Russian Call Girls in Saharanpur Deepika 8250192130 Independent Escort Se...
VIP Russian Call Girls in Saharanpur Deepika 8250192130 Independent Escort Se...Suhani Kapoor
 
Raj Nagar Extension Call Girls 9711199012 WhatsApp No, Delhi Escorts in Raj N...
Raj Nagar Extension Call Girls 9711199012 WhatsApp No, Delhi Escorts in Raj N...Raj Nagar Extension Call Girls 9711199012 WhatsApp No, Delhi Escorts in Raj N...
Raj Nagar Extension Call Girls 9711199012 WhatsApp No, Delhi Escorts in Raj N...ankitnayak356677
 
Captivating Charm: Exploring Marseille's Hillside Villas with Our 3D Architec...
Captivating Charm: Exploring Marseille's Hillside Villas with Our 3D Architec...Captivating Charm: Exploring Marseille's Hillside Villas with Our 3D Architec...
Captivating Charm: Exploring Marseille's Hillside Villas with Our 3D Architec...Yantram Animation Studio Corporation
 
Kindergarten Assessment Questions Via LessonUp
Kindergarten Assessment Questions Via LessonUpKindergarten Assessment Questions Via LessonUp
Kindergarten Assessment Questions Via LessonUpmainac1
 
Bus tracking.pptx ,,,,,,,,,,,,,,,,,,,,,,,,,,
Bus tracking.pptx ,,,,,,,,,,,,,,,,,,,,,,,,,,Bus tracking.pptx ,,,,,,,,,,,,,,,,,,,,,,,,,,
Bus tracking.pptx ,,,,,,,,,,,,,,,,,,,,,,,,,,bhuyansuprit
 
NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...
NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...
NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...Amil baba
 
VIP Call Girl Amravati Aashi 8250192130 Independent Escort Service Amravati
VIP Call Girl Amravati Aashi 8250192130 Independent Escort Service AmravatiVIP Call Girl Amravati Aashi 8250192130 Independent Escort Service Amravati
VIP Call Girl Amravati Aashi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Servicejennyeacort
 
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai DouxDubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Douxkojalkojal131
 
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
A level Digipak development Presentation
A level Digipak development PresentationA level Digipak development Presentation
A level Digipak development Presentationamedia6
 
Kieran Salaria Graphic Design PDF Portfolio
Kieran Salaria Graphic Design PDF PortfolioKieran Salaria Graphic Design PDF Portfolio
Kieran Salaria Graphic Design PDF Portfolioktksalaria
 
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfThe_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfAmirYakdi
 

Recently uploaded (20)

Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
 
Chapter 19_DDA_TOD Policy_First Draft 2012.pdf
Chapter 19_DDA_TOD Policy_First Draft 2012.pdfChapter 19_DDA_TOD Policy_First Draft 2012.pdf
Chapter 19_DDA_TOD Policy_First Draft 2012.pdf
 
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
 
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
 
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
 
VIP Russian Call Girls in Saharanpur Deepika 8250192130 Independent Escort Se...
VIP Russian Call Girls in Saharanpur Deepika 8250192130 Independent Escort Se...VIP Russian Call Girls in Saharanpur Deepika 8250192130 Independent Escort Se...
VIP Russian Call Girls in Saharanpur Deepika 8250192130 Independent Escort Se...
 
Raj Nagar Extension Call Girls 9711199012 WhatsApp No, Delhi Escorts in Raj N...
Raj Nagar Extension Call Girls 9711199012 WhatsApp No, Delhi Escorts in Raj N...Raj Nagar Extension Call Girls 9711199012 WhatsApp No, Delhi Escorts in Raj N...
Raj Nagar Extension Call Girls 9711199012 WhatsApp No, Delhi Escorts in Raj N...
 
Captivating Charm: Exploring Marseille's Hillside Villas with Our 3D Architec...
Captivating Charm: Exploring Marseille's Hillside Villas with Our 3D Architec...Captivating Charm: Exploring Marseille's Hillside Villas with Our 3D Architec...
Captivating Charm: Exploring Marseille's Hillside Villas with Our 3D Architec...
 
Kindergarten Assessment Questions Via LessonUp
Kindergarten Assessment Questions Via LessonUpKindergarten Assessment Questions Via LessonUp
Kindergarten Assessment Questions Via LessonUp
 
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance VVIP 🍎 SER...
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance  VVIP 🍎 SER...Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance  VVIP 🍎 SER...
Call Girls Service Mukherjee Nagar @9999965857 Delhi 🫦 No Advance VVIP 🍎 SER...
 
Bus tracking.pptx ,,,,,,,,,,,,,,,,,,,,,,,,,,
Bus tracking.pptx ,,,,,,,,,,,,,,,,,,,,,,,,,,Bus tracking.pptx ,,,,,,,,,,,,,,,,,,,,,,,,,,
Bus tracking.pptx ,,,,,,,,,,,,,,,,,,,,,,,,,,
 
NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...
NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...
NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...
 
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
 
VIP Call Girl Amravati Aashi 8250192130 Independent Escort Service Amravati
VIP Call Girl Amravati Aashi 8250192130 Independent Escort Service AmravatiVIP Call Girl Amravati Aashi 8250192130 Independent Escort Service Amravati
VIP Call Girl Amravati Aashi 8250192130 Independent Escort Service Amravati
 
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
 
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai DouxDubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
 
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
A level Digipak development Presentation
A level Digipak development PresentationA level Digipak development Presentation
A level Digipak development Presentation
 
Kieran Salaria Graphic Design PDF Portfolio
Kieran Salaria Graphic Design PDF PortfolioKieran Salaria Graphic Design PDF Portfolio
Kieran Salaria Graphic Design PDF Portfolio
 
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfThe_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
 

AOA Week 01.ppt

  • 1. Design and Analysis of Algorithm Week 01
  • 2. Problem Solving  Solving problems is the core of computer science. Programmers must first understand how a human solves a problem, then understand how to translate this "algorithm" into something a computer can do, and finally how to "write" the specific syntax (required by a computer) to get the job done. It is sometimes the case that a machine will solve a problem in a completely different way than a human.
  • 3. Problem Solving Computer Programmers are problem solvers. In order to solve a problem on a computer you must:  Know how to represent the information (data) describing the problem.  Determine the steps to transform the information from one representation into another.
  • 5. Algorithm  An algorithm is a clearly defined set of instructions to be followed to solve a problem. Algorithms are generally created independent of underlying programming languages.  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. 5
  • 6. 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. 6
  • 7. Characteristics of an Algorithm – Finiteness − Algorithms must terminate after a finite number of steps. – Feasibility − Should be feasible with the available resources. – Independent − An algorithm should have step-by-step directions, which should be independent of any programming code.
  • 8. Example  Problem − Design an algorithm to add two numbers and display the result. – Step 1 – START – Step 2 – declare three integers a, b & c – Step 3 – define values of a & b – Step 4 – add values of a & b – Step 5 – store output of Step 4 to c – Step 6 – print c – Step 7 – STOP 8
  • 9. Example  Problem − Design an algorithm to add two numbers and display the result. – Step 1 – START ADD – Step 2 – get values of a & b – Step 3 – c  a + b – Step 4 – display c – Step 5 – STOP  Second method is preferable in Data Structure and Algorithms 9
  • 10. Algorithm Analysis  Efficiency of an algorithm can be analyzed at two different stages, before implementation and after implementation. They are the following − – A Priori Analysis − This is a theoretical analysis of an algorithm. Efficiency of an algorithm is measured by assuming that all other factors, for example, processor speed, are constant and have no effect on the implementation. – A Posterior Analysis − This is an empirical analysis of an algorithm. The selected algorithm is implemented using programming language. This is then executed on target computer machine. In this analysis, actual statistics like running time and space required, are collected 10
  • 11. Pseudo Code and Algorithm  An algorithm is a systematic logical approach used to solve problems in a computer.  Pseudocode is the statement in plain English which may be translated later into a programming language (program).  Pseudo code is an intermediary between an algorithm and implemented program
  • 12. Example Pseudo code to add two numbers:  Take two number inputs  Add numbers using the + operator  Display the result
  • 13. Pseudo Code Example If Ali’s height is greater then 6 feet Then Ali can become a member of the Basket Ball team
  • 14. Conversion from Pseudo code to Source code Pseudo Code If amir’s age is greater than Ammara’s age then show message that amir is elder than amara, otherwise show message that amir is younger than ammara.
  • 15. Conversion from Pseudo code to Source code Source Code if (AmirAge > AmaraAge) { cout<< “Amir is older than Amara” ; } else { cout<<“Amir is younger than or of the same age as Amara” ; }
  • 16. Algorithm : Find the largest number among three numbers  Step 1: Start  Step 2: Declare variables a,b and c.  Step 3: Read variables a,b and c.  Step 4: If a > b  If a > c  Display a is the largest number.  Else  Display c is the largest number.  Else  If b > c  Display b is the largest number.  Else  Display c is the greatest number.  Step 5: Stop
  • 17. Algorithm: Find the factorial of a number  Step 1: Start  Step 2: Declare variables n, factorial and i.  Step 3: Initialize variables  factorial ← 1  i ← 1  Step 4: Read value of n  Step 5: Repeat the steps until i = n  5.1: factorial ← factorial*i  5.2: i ← i+1  Step 6: Display factorial  Step 7: Stop
  • 18. Sorting Problem  we might need to sort a sequence of numbers into non decreasing order. This problem arises frequently in practice and provides fertile ground for introducing many standard design techniques and analysis tools. Here is how we formally define the sorting problem:  Input: A sequence of n numbers (a1, a2,……an).
  • 19. Sorting Problem  For example, given the input sequence (31; 41; 59; 26; 41; 58) a sorting algorithm returns as output the sequence (26; 31; 41; 41; 58; 59). Such an input sequence is called an instance of the sorting problem. In general, an instance of a problem consists of the input (satisfying whatever constraints are imposed in the problem statement) needed to compute a solution to the problem.  Because many programs use it as an intermediate step, sorting is a fundamental operation in computer science. As a result, we have a large number of good sorting algorithms at our disposal. Which algorithm is best for a given application depends on—among other factors—the number of items to be sorted, the extent to which the items are already somewhat sorted, possible restrictions on the item values, the architecture of the computer, and the kind of storage devices to be used: main memory, disks, or even tapes.
  • 20. What kinds of problems are solved by algorithms?  The Human Genome Project has made great progress toward the goals of identifying all the 100,000 genes in human DNA, determining the sequences of the 3 billion chemical base pairs that make up human DNA, storing this information in databases, and developing tools for data analysis. Each of these steps requires sophisticated algorithms.  The Internet enables people all around the world to quickly access and retrieve large amounts of information. With the aid of clever algorithms, sites on the internet are able to manage and manipulate this large volume of data. Examples of problems that make essential use of algorithms include finding good routes.  Electronic commerce enables goods and services to be negotiated and exchanged electronically, and it depends on the privacy of personal information such as credit card numbers, passwords, and bank statements. The core technologies used in electronic commerce include public-key cryptography and digital signatures which are based on numerical algorithms and number theory.
  • 21. What kinds of problems are solved by algorithms?  Manufacturing and other commercial enterprises often need to allocate scarce resources in the most beneficial way.  An oil company may wish to know where to place its wells in order to maximize its expected profit.  A political candidate may want to determine where to spend money buying campaign advertising in order to maximize the chances of winning an election.  An airline may wish to assign crews to flights in the least expensive way possible, making sure that each flight is covered and that government regulations regarding crew scheduling are met.  An Internet service provider may wish to determine where to place additional resources in order to serve its customers more effectively. All of these are examples of problems that can be solved using linear programming algos.