Computer Programming Algorithms

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 29

ALGORITHMS

6.53

COMPUTER PROGRAMMING GRADE 11


AND 12
EXPECTATION

• At the end of the lesson, the students


should be able to:
• 1.understand standard algorithm; and
• 2.code using standard algorithms.

7/1/20XX Pitch deck title 2


TECHNICAL TERMS

• Algorithm – the step-by-step procedure of solving a


problem.
• End point - the final stage of a period or process.
• Outcome - the way a thing turns out; a consequence.
• Starting point - a place or position where something
begins; a place or position where something begins.

7/1/20XX Pitch deck title 3


PRE-TEST

Multiple Choice: Choose the letter of the correct answer that


referred to the statements below on the steps in writing an
algorithm.
1. To determine the outcome of your code, one must know?
a. What is the specific problem you want to solve or the task
you want it to accomplish?
b. What facts will we learn from the process?
c. What formulas are applicable to the issue at hand?
d. What will be added or no longer exist?

7/1/20XX Pitch deck title 4


PRE-TEST

Multiple Choice: Choose the letter of the correct answer that


referred to the statements below on the steps in writing an
algorithm.
2. Finding your starting and ending point are crucial to listing the
steps of the process. To determine a starting point, determine the
answer to these questions, except?
a. What data/inputs are available?
b. Where is that data located?
c. What facts will we learn from the process?
d. What formulas are applicable to the issue at hand?
7/1/20XX Pitch deck title 5
PRE-TEST

Multiple Choice: Choose the letter of the correct answer that


referred to the statements below on the steps in writing an
algorithm.
3. As with the starting point, you can find the end point of your
algorithm by focusing on these questions, except?
a. What facts will we learn from the process?
b. What changes from the start to the end?
c. What will be added or no longer exist?
d. How do the data values relate to each other?

7/1/20XX Pitch deck title 6


PRE-TEST

Multiple Choice: Choose the letter of the correct answer that


referred to the statements below on the steps in writing an algorithm.
4. To use a real-world example, let’s say your goal is to have
lasagna for dinner. You’ve determined that the starting point is to find
a recipe, and that the end result is that you’ll have a lasagna fully
cooked and ready to eat by 7 PM. What will you do?
a. Determine how will you accomplish each step.
b. List the steps from start to finish.
c. Find the ending point of the algorithm.
d. Determine the outcome of your code.
7/1/20XX Pitch deck title 7
PRE-TEST
Multiple Choice: Choose the letter of the correct answer
that referred to the statements below on the steps in
writing an algorithm.
5. Now that you’ve written your algorithm, it’s time to
evaluate the process by?
a. Review the algorithm.
b. List the steps from start to finish.
c. Find the ending point of the algorithm.
d. Determine how will you accomplish each step.
7/1/20XX Pitch deck title 8
WHAT IS AN ALGORITHM?
• Generally, an algorithm is a step-by-step procedure to solve
problems. A guide for isntalling new software, a manual for
assembling appliances, and even recipes are examples of an
algorithm. In programming, making an algorithm is exciting, they
are expressed in a programming language or in a pseudocode.
• Algorithm makes the whole procedure more efficient as well as
consistent. It also helps in identifying decision points, processes,
and essential variables to solve the problem. A programmer can
also see and determine easily the errors in a particular process
using an algorithm.

7/1/20XX Pitch deck title 9


STEPS IN WRITING AN ALGORITHM IN
PROGRAMMING

1. Determine the outcome of your code. What is the specific


problem you want to solve or the task you want it to accomplish?
2. Decide on a starting point. Finding your starting and ending point are crucial
to listing the steps of the process. To determine a starting point, determine the
answers to these questions:
• • What data/inputs are available?
• • Where is that data located?
• • What formulas are applicable to the issue at hand?
• • What are the rules to working with the available data?
• • How do the data values relate to each other?

7/1/20XX Pitch deck title 10


STEPS IN WRITING AN ALGORITHM IN
PROGRAMMING
3. Find the ending point of the algorithm. As with the starting point, you
can find the end point of your algorithm by focusing on these questions:
• What facts will we learn from the process?
• What changes from the start to the end?
• What will be added or no longer exist?

4. List the steps from start to finish. Start with broad steps. To use a
real-world example, let's say your goal is to have lasagna for dinner. You've
determined that the starting point is to find a recipe, and that the end result
is that you'll have a lasagna fully cooked and ready to eat by 7 PM

7/1/20XX Pitch deck title 11


STEPS IN WRITING AN ALGORITHM IN
PROGRAMMING
5. Determine how you will accomplish each step. Now that
you have a step-by-step outline, it's time to think about how you
might code each step.

6. Review the algorithm. Now that you've written your


algorithm, it's time to evaluate the process. Your algorithm is
designed to accomplish something specific, and you'll need it to
start writing your program.

7/1/20XX Pitch deck title 12


PROGRAMMING ALGORITHM
• You probably wish you could see an example, right? So, what exactly
does an algorithm in programming look like? Well, asking a user for an
email address is probably one of the most common tasks a web-based
program might need to do, so that is what we will use here for an
example. An algorithm can be written as a list of steps using text. We will
make one of each which you will see here:
• Wasn't that easy? Notice how the top of our example is just a numbered
list of steps using plain English, stating exactly what we want the
procedure to do (no more, no less). That's a nice thing here, because in
one of our steps (step 7) a decision must be made and, depending on the
result of that decision, our steps may not go in order from start to end.

7/1/20XX Pitch deck title 13


PROGRAMMING ALGORITHM
Let's take a quick run through our little recipe:
1. Step 1 is really just a reminder that this is a procedure with a beginning and
an end.
2. In step 2, we make a place in the computer to store what the user types in,
also called a variable
3. In step 3, we clear this variable because we might need to use it again and
don't want the old contents mixed in with the new.
4. In step 4, we prompt the user for an email address
5. In step 5, we stick it in our nifty variable.
6. In step 6, we tell our computer to take a close look at this email address-- is
it really an email address?
7/1/20XX Pitch deck title 14
PROGRAMMING ALGORITHM

7/1/20XX Pitch deck title 15


ALGORITHM EXAMPLES

7/1/20XX Pitch deck title 16


ALGORITHM EXAMPLES

7/1/20XX Pitch deck title 17


SAMPLE PROBLEM

•Write An algorithm that adds


2 numbers.
•Write an algorithm that
multiplies 2 numbers.
7/1/20XX Pitch deck title 18
SAMPLE PROBLEM WITH IF STATEMENT

•Algorithm 2: Find the


largest number among
three numbers

7/1/20XX Pitch deck title 19


SAMPLE PROBLEM

•Write an algorithm that


Adds two numbers
entered by the user

7/1/20XX Pitch deck title 20


ACTIVITIES

1. Write an algorithm to print 1 to 20.


2. Write an algorithm to Convert temperature: Fahrenheit
to Celsius. C=5/9*(F-32)
3. Write an algorithm that will calculate the roots of a
quadratic equation ax2+bx+c=0. Hint: d=sqrt(b2-4ac),
and the roots are: x1=(-b+d)/2a and x2=(-b-d)/2a
4. Write an algorithm that reads two values, determine
the largest value and prints the largest value with an
identifying message.
7/1/20XX Pitch deck title 21
REMEMBERING

•An algorithm shows you every step


of reaching the final solution. An
algorithm uses mainly words to
describe the steps to make the
process understandable.

7/1/20XX Pitch deck title 22


CHECK YOUR UNDERSTANDING
Direction: Write your understanding
about the following:
•How can an algorithm help in making
an efficient program?

7/1/20XX Pitch deck title 23


POST-TEST

• Multiple Choice: Choose the letter of the correct answer that


referred to the statements below on the steps in writing an
algorithm.
1. To determine the outcome of your code, one must know?
• A. What is the specific problem you want to solve or the task
you want it to accomplish?
• B. What facts will we learn from the process?
• C. What formulas are applicable to the issue at hand?
• D. What will be added or no longer exist?

7/1/20XX Pitch deck title 24


POST-TEST

• Multiple Choice: Choose the letter of the correct answer that


referred to the statements below on the steps in writing an
algorithm.
2. Finding your starting and ending point are crucial to listing the
steps of the process. To determine a starting point, determine the
answer to these questions, except?
• A. What data/inputs are available?
• B. Where is that data located?
• C. What facts will we learn from the process?
• D. What formulas are applicable to the issue at hand?
7/1/20XX Pitch deck title 25
POST-TEST
3. As with the starting point, you can find the end point
of your algorithm by focusing on these questions,
except?
• A. What facts will we learn from the process?
• B. What changes from the start to the end?
• C. What will be added or no longer exist?
• D. How do the data values relate to each other?

7/1/20XX Pitch deck title 26


POST-TEST
4. To use a real-world example, let’s say your goal is to
have lasagna for dinner. You’ve determined that the
starting point is to find a recipe, and that the end result
is that you’ll have a lasagna fully cooked and ready to
eat by 7 PM. What will you do?
• A. Determine how will you accomplish each step.
• B. List the steps from start to finish.
• C. Find the ending point of the algorithm.
• D. Determine the outcome of your code.
7/1/20XX Pitch deck title 27
POST-TEST
5. Now that you’ve written your algorithm, it’s
time to evaluate the process by?
• A. Review the algorithm.
• B. List the steps from start to finish.
• C. Find the ending point of the algorithm.
• D. Determine how will you accomplish each
step.
7/1/20XX Pitch deck title 28
THANK YOU
Mirjam Nilsson​
206-555-0146
[email protected]
www.contoso.com

7/1/20XX Pitch deck title 29

You might also like