0% found this document useful (0 votes)
13 views

Data Structures and Algorithmn

data structures and algorithms key answers
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Data Structures and Algorithmn

data structures and algorithms key answers
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

ALGORITHM

AND
FLOWCHARTIN
Lesson 2 – Data Structures and

G
Algorithm

MR. ROWELL L.
MARQUINA
IT Instructor, PUP
WHAT IS
AN
ALGORITHM
?
What is an
Algorithm?
An algorithm refers to a series of well-
defined instructions on how to accomplish
a task or solve a specific problem.
 Giving directions on how to get to
somebody’s house is an algorithm.
 The steps on how to change a light bulb
is an algorithm.
 The steps to compute the for average
is also an algorithm.

IMAGE SOURCE: https://imgbin.com/png/uxvDNRys/computer-programming-computer-icons-technology-algorithm-png


https://www.flaticon.com/free-icon/coding_1085774
STEPS IN DEVELOPING AN
ALGORITHM:
1. In creating an algorithm, it is very important to determine
the exact goal or expected product first. The goal or
expected product of the algorithm is called OUTPUT.
2. After determining the output, the next step is to identify
the necessary materials or elements needed to
accomplish the task. The elements needed for the
program is called INPUT.
3. If the input and output are already identified, it is time to
list the steps needed to accomplish the task. The steps
needed to accomplish the task is referred to as the
PROCESS.
CHARACTERISTICS OF AN
ALGORITHM:
An algorithm should possess the following
characteristics:
 It should have well-defined input and output.
 The steps should be stated clearly and unambiguously.
 It should have an exact start and end.
 It should be simple but precise.
 It should be practical.
WHAT IS
FLOWCHAR
T?
What is a
Flowchart?
A flowchart is a diagram
that illustrates a process,
system or computer
algorithm.
Flowcharts are widely used in
multiple fields for the purpose
of:
 documentation
 planning
 analysis
 presentation
IMAGE SOURCE: https://www.frevvo.com/blog/wp-content/uploads/2021/10/image5-2.png
Flowchart
Symbols
The American National
Standards Institute (ANSI) set
standards for flowcharts and
their symbols in the 1960s.
In 1970 the International
Organization for
Standardization (ISO) adopted the
ANSI symbols as the international
standard for developing flowcharts.

IMAGE SOURCES:
https://upload.wikimedia.org/wikipedia/commons/thumb/9/93/ANSI_logo.svg/1200px-ANSI_logo.svg.png
https://1000logos.net/wp-content/uploads/2020/09/ISO-Logo.png
Flowchart
Symbols

IMAGE SOURCES:
https://uploads-ssl.webflow.com/6184b461a39ff13bfb8c0556/61de99e8171cc6468145551d_flowchart-symbols-800.png
Flowchart
Symbols
NAME OF SYMBOL SYMBOL FUNCTION
Indicates the beginning and end of
Terminal Symbol
the flowchart.
Its shows the process’ direction or the
Flowline Symbol
next steps in the process.
It shows the process or operations to
Process Symbol
be carried out by the program

It shows the step that contains a


Decision Symbol
control mechanism or decision.

It indicates the process of getting


Input/Output Symbol data from the user or displaying
data on screen.
SAMPLE FLOWCHART
1:
DETERMINING USER’S AGE
Create a flowchart for a program that will
require the user to input their year of birth.
Using the user’s year of birth, the program
will compute for the user’s age and display
its result on the computer screen.
STAR The program is
T initiated.
The variables birthyear and age were introduced to
birthyear, age
the program.

display The program displays the instruction “Enter Year of


“Enter Year of Birth:” Birth: ”
on the screen.

input The program get an input from the user and store its
birthyear value in the variable birthyear.

The program computes for the value of age using


age = 2023 - birthyear
the formula age = 2023 - birthyear.

display
The program displays the value of age on the
age
screen.

END The program is


terminated.
SAMPLE FLOWCHART
2:
CONVERTING FROM KILOGRAM TO POUND
Create a flowchart for a program that will
require the user to input a value in kilogram
(kg). The program will convert the inputted
value into pounds (lbs.) and display its results
on the screen.
STAR The program is
T initiated.
The variables kilo and pound were introduced to
kilo, pound
the program.

display
The program displays the instruction “Enter
“Enter Weight in
Weight in
Kilogram:”
Kilogram: ” on the screen.

input The program get an input from the user and store its
kilo value in the variable kilogram.

pound = kilo * 2.2 The program computes for the value of pound using
the formula pound = kilo * 2.2.

display
pound The program displays the value of pound on the
screen.

The program is
END
terminated.
SAMPLE FLOWCHART
3:
COMPUTING FOR AREA:
Create a flowchart for a program that will
require the user to input the length and width
of a rectangle. The program will compute for
the area of the rectangle using the inputted
length and with and display its results on the
screen.
STAR The program is
T initiated.

length, width, area The variables length, width, and area were
introduced to the program.

display The program displays the instruction “Enter Length:


“Enter Length:” ” on the screen.

input The program get an input from the user and store its
length value in
the variable length.

display The program displays the instruction “Enter Width:


“Enter Width:” ” on
the screen.

input The program get an input from the user and store its
width value in the variable width.

A The program will be continued on the next


slide.
A The program is
continued.

area = length * width The program computes for the value of area using
the formula area = length*width.

display
The program displays the value of area on the
area
screen.

END The program is


terminated.
SAMPLE FLOWCHART
4:
PLAYING WITH NUMBERS
Create a flowchart for a program that will
require the user to input four numbers. Using
the inputs, the program will compute for:
 the sum of 1st and 2nd number,
 the product of the 3rd and 4th
number
 the square of the 2nd number
STAR The program is
T initiated.
num1, num2, num3, num4, The variables num1, num2, num3, num4, sum,
sum, product, square product, and square were introduced to the
program.
display The program displays the instruction “Enter the
“Enter the First First Number: ” on the screen.
Number: ”

input The program get an input from the user and store its
num1 value in
the variable num1.
display The program displays the instruction “Enter the
“Enter the Second Second
Number: ” N u m b er: ” on the screen.

input The program get an input from the user and store its
value in the variable num2.
num2
A The program will be continued on the next
slide.
A
The program is
continued.
display The program displays the instruction
“Enter the Third “Enter the Third Number: ” on the
Number: ” screen.

input The program get an input from the user and store its
value in the variable num3.
num3
display The program displays the instruction
“Enter the Fourth “Enter the Fourth Number: ” on the
Number: ” screen.

input The program get an input from the user and store its
value in the variable num4.
num4
The program computes for the value of sum using
sum = num1 + num2
the formula sum = a + b.

B The program will be continued on the next


slide.
B The program is
continued.
The program computes for the value of product
product = num3 * num4
using the formula product = num3*num4.

The program computes for the value of square


square = num2 * num2 using the formula square = num2 * num2.

display
The program displays the value of sum on the
sum
screen.

display The program displays the value of product on the


product screen.

display
The program displays the value of square on the
square
screen.

END The program is


terminated.
SAMPLE FLOWCHART
5:
PLAYING WITH NUMBERS
Create a flowchart for a program that will
require the user to input four numbers. Using
the inputs, the program will compute for:
 the cube of the 1st number,
 the half of the 2nd number,
 the 20% of the 3rd number,
 The product of multiplying the
4th number by 100
STAR The program is initiated.
T
The variables num1, num2, num3, num4,
num1, num2, num3, num4,
cube, half, twentyp, and times100 were
cube, half, twentyp, times100
introduced to the program.

display The program displays the instruction “Enter the


“Enter the First First Number: ” on the screen.
Number: ”

input The program get an input from the user and store its
num1 value in
the variable num1.
display The program displays the instruction “Enter the
“Enter the Second Second
Number: ” N u m b er: ” on the screen.

input The program get an input from the user and store its
value in the variable num2.
num2
A The program will be continued on the next
slide.
A
The program is
continued.
display The program displays the instruction
“Enter the Third “Enter the Third Number: ” on the
Number: ” screen.

input The program get an input from the user and store its
value in the variable num3.
num3
display The program displays the instruction
“Enter the Fourth “Enter the Fourth Number: ” on the
Number: ” screen.

input The program get an input from the user and store its
value in the variable num4.
num4
The program computes for the value of cube using
cube = num1 * num1 * num1
the formula cube = num1 * num1 * num1.

B The program will be continued on the next


slide.
B The program is continued.

The program computes for the value of half using


half = num2 / 2
the formula half = num2 / 2.

twentyp = num3 * 0.20 The program computes for the value of twentyp
using the formula twentyp = num3 * 0.20.
The program computes for the value of times100
times100 = num4 * 100
using the formula times100 = num4 * 100.

display The program displays the value of cube on the


cube screen.

display
The program displays the value of half on the
half
screen.
display The program displays the value of twentyp on the
twentyp screen.

display The program displays the value of times100 on the


times100 screen.

END The program is


terminated.
PRACTICE TEST
1:
DOLLAR TO PESO CONVERSION
Create a flowchart for a program that will
require the user to input the amount in US
Dollars. Using the inputted amount, the
program will convert it to its Philippine Peso
value and display the answer on the screen.
Note: 1 US Dollar = Php 56.78
PRACTICE TEST
2:
COMPUTING FOR AVERAGE
Create a flowchart for a program that will
require the user to input their grades in
Mathematics, English, and Science. The
program will compute for the average of the
three grades and display its result on the
computer screen.
PRACTICE TEST
3:
PLAYING WITH NUMBERS
Create a flowchart for a program that will
require the user to input four numbers. Using
the inputs, the program will perform the
following:
 display the 1st number,
 get the product of 1st and 3rd number,
 get the product of multiplying the 2nd
number by the sum of the 3rd and 4th
number,
 the average of the four numbers increased
ALGORITHM
AND
FLOWCHARTIN
GMARQUINA
MR. ROWELL L.

Professional Lecturer,
Polytechnic University of the
Philippines

Email Address: rowell.marquina


[email protected]
[email protected]
[email protected]

You might also like