2. Algorithm
ï±finite set of instructions that specify a sequence of
operations to be carried out.
ï± Algorithm design isnât easy, but itâs not impossible
either. People who design algorithms donât sit
around looking for problems to solve, they are
usually already involved in projects when a
problem arises that requires a solution.
3. ï±This might not sound that hard because people
tend to put algorithms in the same class as
functions. However, they are not functions, they are
efficient paths to handling data as accurately and
quickly as the computer allows.
ï±Algorithms resemble recipes. Recipes tell you how
to accomplish a task by performing a number of
steps.
ï±For example, to bake a cake the steps are: preheat
the oven; mix flour, sugar, and eggs thoroughly;
pour into a baking pan; and so forth.
5. Described below are the four stages of
algorithm analysis and design:
ï¶Design
ï± The first stage is to identify the problem and thoroughly understand it.
This is where itâs important you consult with everybody who has an
interest in the problem. Speak with them and see how they see the
problem and what they need out of the solution so their part of the
project or program can progress.
ï± This is also the point where you are going to flowchart and/or use
pseudo code to work out the specific problems of solving the flow of
operations within the code.
6. ï¶ Analyze
ï± Once you have the basic framework of the algorithm itâs time to start
analyzing how efficient the code is in solving the problem. Algorithm
design is fluid and subject to individual plans. This is a step that some
programmers like to attack after they have coded the algorithm and run
it through the compiler. Others prefer to examine it prior to writing the
code and analyze results based on their expectations from the design
stage.
ï± If you are part of a team then have the best programmer in your group
write the initial code, notate it well so the lesser experienced
programmers will understand what is happening as the application is
executed.
7. ï¶ Implement
âą Writing and coding the algorithm is the next step in the
process. If you are the one writing the algorithm, then you
need to write it in the coding language you understand
the best. In order for you to know how to write the
algorithm efficiently you have to know exactly what each
line of code is going to accomplish when the program is
executed. Write the code to execute quickly but can also
handle the input data that it will receive.
âą If you are part of a team then have the best programmer
in your group write the initial code, notate it well so the
lesser experienced programmers will understand what is
happening as the application is executed.
8. ï¶ Experiment
ï± Once the algorithm is designed and coded go back and
experiment with different variables in the algorithm. Try
and enter data that will make it fail or try and re-write the
code to work it out most efficiently. Experimentation in
algorithmic design is really just another step of the
analyzing of the algorithm.
ï± When you find flaws in what you have written or ways to
write the code better, then go back to the design step and
redesign the algorithm.
10. âą Let's say that you have a friend arriving at the airport, and your friend
needs to get from the airport to your house. Here are three different
algorithms that you might give your friend for getting to your home:
ï± The taxi algorithm:
âą 1. Go to the taxi stand.
âą 2. Get in a taxi.
âą 3. Give the driver my address.
ï± The call-me algorithm:
âą 1. When your plane arrives, call my cell phone.
âą 2. Meet me outside baggage claim.
ï± The rent-a-car algorithm:
âą 1. Take the shuttle to the rental car place.
âą 2. Rent a car.
âą 3. Follow the directions to get to my house
11. ï± Write an algorithm to add two numbers entered
by user.
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result to
sum.
sumânum1+num2
Step 5: Display sum
Step 6: Stop
12. Analysis of Algorithms
"Analysis of algorithms is the theoretical study of
computer program performance and resource usage".
ï±How good is the Algorithm?
ïŒ correctness
ïŒ time efficiency
ïŒ space efficiency
ïŒ security
ïŒ functionality
ïŒ robustness
ïŒ user-friendliness
13.
14. Quiz:
1-4 .What are the phases of Algorithm design.
5. Analysis of algorithms is the
of computer program
performance and resource usage.
6-8. Give 3 examples of characteristic of
Analysis of Algorithm.
9-10. Write algorithms that is used in real life
and in Programming.