SlideShare a Scribd company logo
1 of 29
Download to read offline
ALGORITHM AND
FLOWCHARTING
Lesson 2 – Data Structures and Algorithm
MR. ROWELL L. MARQUINA
IT Instructor, PUP Biñan
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.
IMAGE SOURCE: https://imgbin.com/png/uxvDNRys/computer-programming-computer-icons-technology-algorithm-png
https://www.flaticon.com/free-icon/coding_1085774
▪ 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.
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
FLOWCHART?
What is a Flowchart?
A flowchart is a diagram that
illustrates a process, system or
computer algorithm.
IMAGE SOURCE: https://www.frevvo.com/blog/wp-content/uploads/2021/10/image5-2.png
Flowcharts are widely used in
multiple fields for the purpose of:
▪ documentation
▪ planning
▪ analysis
▪ presentation
Flowchart Symbols
The American National Standards
Institute (ANSI) set standards for
flowcharts and their symbols in the
1960s.
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
In 1970 the International Organization
for Standardization (ISO) adopted the
ANSI symbols as the international
standard for developing flowcharts.
Flowchart Symbols
IMAGE SOURCES:
https://uploads-ssl.webflow.com/6184b461a39ff13bfb8c0556/61de99e8171cc6468145551d_flowchart-symbols-800.png
Flowchart Symbols
NAME OF SYMBOL SYMBOL FUNCTION
Terminal Symbol
Indicates the beginning and end of the
flowchart.
Flowline Symbol
Its shows the process’ direction or the
next steps in the process.
Process Symbol
It shows the process or operations to be
carried out by the program
Decision Symbol
It shows the step that contains a control
mechanism or decision.
Input/Output Symbol
It indicates the process of getting 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.
START
birthyear, age
display
“Enter Year of Birth:”
input
birthyear
age = 2023 - birthyear
display
age
END
The program is initiated.
The variables birthyear and age were introduced to the
program.
The program displays the instruction “Enter Year of Birth: ”
on the screen.
The program get an input from the user and store its value in
the variable birthyear.
The program computes for the value of age using the
formula age = 2023 - birthyear.
The program displays the value of age on the screen.
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.
START
kilo, pound
display
“Enter Weight in
Kilogram:”
input
kilo
pound = kilo * 2.2
display
pound
END
The program is initiated.
The variables kilo and pound were introduced to the
program.
The program displays the instruction “Enter Weight in
Kilogram: ” on the screen.
The program get an input from the user and store its value in
the variable kilogram.
The program computes for the value of pound using the
formula pound = kilo * 2.2.
The program displays the value of pound on the screen.
The program is 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.
START
length, width, area
display
“Enter Length:”
input
length
The program is initiated.
The variables length, width, and area were introduced to
the program.
The program displays the instruction “Enter Length: ” on
the screen.
The program get an input from the user and store its value in
the variable length.
The program displays the instruction “Enter Width: ” on
the screen.
The program get an input from the user and store its value
in the variable width.
The program will be continued on the next slide.
display
“Enter Width:”
input
width
A
area = length * width
display
area
The program is continued.
The program computes for the value of area using the
formula area = length*width.
The program displays the value of area on the screen.
The program is terminated.
A
END
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
START
num1, num2, num3, num4,
sum, product, square
display
“Enter the First
Number: ”
input
num1
The program is initiated.
The variables num1, num2, num3, num4, sum,
product, and square were introduced to the program.
The program displays the instruction “Enter the First
Number: ” on the screen.
The program get an input from the user and store its value in
the variable num1.
The program displays the instruction “Enter the Second
Number: ” on the screen.
The program get an input from the user and store its value
in the variable num2.
The program will be continued on the next slide.
display
“Enter the Second
Number: ”
input
num2
A
display
“Enter the Third
Number: ”
input
num3
The program is continued.
The program displays the instruction
“Enter the Third Number: ” on the screen.
The program get an input from the user and store its value in
the variable num3.
The program displays the instruction
“Enter the Fourth Number: ” on the screen.
The program get an input from the user and store its value
in the variable num4.
The program will be continued on the next slide.
display
“Enter the Fourth
Number: ”
input
num4
B
A
sum = num1 + num2
The program computes for the value of sum using the
formula sum = a + b.
display
sum
The program is continued.
The program is terminated.
display
square
B
product = num3 * num4
The program computes for the value of product using
the formula product = num3*num4.
square = num2 * num2
display
product
END
The program computes for the value of square using
the formula square = num2 * num2.
The program displays the value of sum on the screen.
The program displays the value of product on the screen.
The program displays the value of square on the screen.
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
START
num1, num2, num3, num4,
cube, half, twentyp, times100
display
“Enter the First
Number: ”
input
num1
The program is initiated.
The variables num1, num2, num3, num4, cube, half,
twentyp, and times100 were introduced to the
program.
The program displays the instruction “Enter the First
Number: ” on the screen.
The program get an input from the user and store its value in
the variable num1.
The program displays the instruction “Enter the Second
Number: ” on the screen.
The program get an input from the user and store its value
in the variable num2.
The program will be continued on the next slide.
display
“Enter the Second
Number: ”
input
num2
A
display
“Enter the Third
Number: ”
input
num3
The program is continued.
The program displays the instruction
“Enter the Third Number: ” on the screen.
The program get an input from the user and store its value in
the variable num3.
The program displays the instruction
“Enter the Fourth Number: ” on the screen.
The program get an input from the user and store its value
in the variable num4.
The program will be continued on the next slide.
display
“Enter the Fourth
Number: ”
input
num4
B
A
cube = num1 * num1 * num1
The program computes for the value of cube using the
formula cube = num1 * num1 * num1.
The program is continued.
The program is terminated.
B
half = num2 / 2
The program computes for the value of half using the
formula half = num2 / 2.
twentyp = num3 * 0.20
END
The program computes for the value of twentyp using
the formula twentyp = num3 * 0.20.
The program displays the value of cube on the screen.
The program displays the value of half on the screen.
The program displays the value of twentyp on the screen.
times100 = num4 * 100
display
cube
display
half
display
twentyp
display
times100
The program computes for the value of times100
using the formula times100 = num4 * 100.
The program displays the value of times100 on the screen.
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 by 5.
ALGORITHM AND
FLOWCHARTING
MR. ROWELL L. MARQUINA
Professional Lecturer,
Polytechnic University of the Philippines
Email Address:
rowell.marquina001@deped.gov.ph
sirrowellmarquina@gmail.com
rmarquina@mitis.edu.ph

More Related Content

What's hot

Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
Varun Garg
 

What's hot (20)

introduction to visual basic PPT.pptx
introduction to visual basic PPT.pptxintroduction to visual basic PPT.pptx
introduction to visual basic PPT.pptx
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 
Libre Office Impress Lesson 1
Libre Office Impress Lesson 1Libre Office Impress Lesson 1
Libre Office Impress Lesson 1
 
INTRODUCTION TO FLUTTER.pdf
INTRODUCTION TO FLUTTER.pdfINTRODUCTION TO FLUTTER.pdf
INTRODUCTION TO FLUTTER.pdf
 
Adobe Photoshop Tools
Adobe Photoshop ToolsAdobe Photoshop Tools
Adobe Photoshop Tools
 
Introduction to qbasic
Introduction to qbasicIntroduction to qbasic
Introduction to qbasic
 
Algorithm and flowchart
Algorithm and flowchart Algorithm and flowchart
Algorithm and flowchart
 
Converter - C- Language Program
Converter - C- Language ProgramConverter - C- Language Program
Converter - C- Language Program
 
Visual Basic 6.0
Visual Basic 6.0Visual Basic 6.0
Visual Basic 6.0
 
Basic exercises for photoshop
Basic exercises for photoshopBasic exercises for photoshop
Basic exercises for photoshop
 
structured programming Introduction to c fundamentals
structured programming Introduction to c fundamentalsstructured programming Introduction to c fundamentals
structured programming Introduction to c fundamentals
 
Photoshop Guide
Photoshop GuidePhotoshop Guide
Photoshop Guide
 
Scratch Animation
Scratch AnimationScratch Animation
Scratch Animation
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
 
Scratch Programming
Scratch ProgrammingScratch Programming
Scratch Programming
 
Qbasic introduction
Qbasic introductionQbasic introduction
Qbasic introduction
 
Introduction to photoshop
Introduction to photoshopIntroduction to photoshop
Introduction to photoshop
 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
 
DAY 1 - Introduction to Photo Editing and Photoshop CS6
DAY 1 - Introduction to Photo Editing and Photoshop CS6DAY 1 - Introduction to Photo Editing and Photoshop CS6
DAY 1 - Introduction to Photo Editing and Photoshop CS6
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 

Similar to DSA Lesson 2 - Algorithm and Flowcharting.pdf

Lesson 1 - Algorithm and Flowcharting.pdf
Lesson 1 - Algorithm and Flowcharting.pdfLesson 1 - Algorithm and Flowcharting.pdf
Lesson 1 - Algorithm and Flowcharting.pdf
ROWELL MARQUINA
 
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docxBottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
AASTHA76
 
California State University, Fullerton College of Engineerin.docx
California State University, Fullerton College of Engineerin.docxCalifornia State University, Fullerton College of Engineerin.docx
California State University, Fullerton College of Engineerin.docx
humphrieskalyn
 
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docxCMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
clarebernice
 
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming  EECS 1.docxProject 2Project 2.pdfIntroduction to Programming  EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
wkyra78
 
Year 2 dsa c++ exercises on user defined functions
Year 2 dsa  c++ exercises on user defined functionsYear 2 dsa  c++ exercises on user defined functions
Year 2 dsa c++ exercises on user defined functions
ErnesteNtezirizaza
 
INTRODUCTION The goal of this programming project is to entble studen.pdf
 INTRODUCTION The goal of this programming project is to entble studen.pdf INTRODUCTION The goal of this programming project is to entble studen.pdf
INTRODUCTION The goal of this programming project is to entble studen.pdf
ameancal
 
Cis355 a ilab 2 control structures and user defined methods devry university
Cis355 a ilab 2 control structures and user defined methods devry universityCis355 a ilab 2 control structures and user defined methods devry university
Cis355 a ilab 2 control structures and user defined methods devry university
sjskjd709707
 

Similar to DSA Lesson 2 - Algorithm and Flowcharting.pdf (20)

Lesson 1 - Algorithm and Flowcharting.pdf
Lesson 1 - Algorithm and Flowcharting.pdfLesson 1 - Algorithm and Flowcharting.pdf
Lesson 1 - Algorithm and Flowcharting.pdf
 
Programming Fundamental handouts
Programming Fundamental handoutsProgramming Fundamental handouts
Programming Fundamental handouts
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
 
Lesson 5 - Getting Input from Users.pdf
Lesson 5 - Getting Input from Users.pdfLesson 5 - Getting Input from Users.pdf
Lesson 5 - Getting Input from Users.pdf
 
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docxBottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
 
C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17
 
California State University, Fullerton College of Engineerin.docx
California State University, Fullerton College of Engineerin.docxCalifornia State University, Fullerton College of Engineerin.docx
California State University, Fullerton College of Engineerin.docx
 
CBCS 2018 Scheme I sem Lab Manual for 18CPL17
CBCS 2018 Scheme I sem Lab Manual for 18CPL17 CBCS 2018 Scheme I sem Lab Manual for 18CPL17
CBCS 2018 Scheme I sem Lab Manual for 18CPL17
 
EC6612 VLSI Design Lab Manual
EC6612 VLSI Design Lab ManualEC6612 VLSI Design Lab Manual
EC6612 VLSI Design Lab Manual
 
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docxCMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
 
Chapter 2- Prog101.ppt
Chapter 2- Prog101.pptChapter 2- Prog101.ppt
Chapter 2- Prog101.ppt
 
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming  EECS 1.docxProject 2Project 2.pdfIntroduction to Programming  EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
 
c++ Question
c++  Questionc++  Question
c++ Question
 
Year 2 dsa c++ exercises on user defined functions
Year 2 dsa  c++ exercises on user defined functionsYear 2 dsa  c++ exercises on user defined functions
Year 2 dsa c++ exercises on user defined functions
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
 
CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   CIS 170 Life of the Mind/newtonhelp.com   
CIS 170 Life of the Mind/newtonhelp.com   
 
CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   CIS 170 Imagine Your Future/newtonhelp.com   
CIS 170 Imagine Your Future/newtonhelp.com   
 
INTRODUCTION The goal of this programming project is to entble studen.pdf
 INTRODUCTION The goal of this programming project is to entble studen.pdf INTRODUCTION The goal of this programming project is to entble studen.pdf
INTRODUCTION The goal of this programming project is to entble studen.pdf
 
Cis355 a ilab 2 control structures and user defined methods devry university
Cis355 a ilab 2 control structures and user defined methods devry universityCis355 a ilab 2 control structures and user defined methods devry university
Cis355 a ilab 2 control structures and user defined methods devry university
 

More from ROWELL MARQUINA

QMMS Lesson 2 - Using Excel Formula.pptx
QMMS Lesson 2 - Using Excel Formula.pptxQMMS Lesson 2 - Using Excel Formula.pptx
QMMS Lesson 2 - Using Excel Formula.pptx
ROWELL MARQUINA
 
HCI Lesson 2 - Components of Human-Computer Interaction (HCI).pdf
HCI Lesson 2 - Components of Human-Computer Interaction (HCI).pdfHCI Lesson 2 - Components of Human-Computer Interaction (HCI).pdf
HCI Lesson 2 - Components of Human-Computer Interaction (HCI).pdf
ROWELL MARQUINA
 
ITSP Lesson 1 - Ethics and Ethical Theories.pdf
ITSP Lesson 1 - Ethics and Ethical Theories.pdfITSP Lesson 1 - Ethics and Ethical Theories.pdf
ITSP Lesson 1 - Ethics and Ethical Theories.pdf
ROWELL MARQUINA
 

More from ROWELL MARQUINA (19)

QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdf
 
QMMS Lesson 2 - Using Excel Formula.pptx
QMMS Lesson 2 - Using Excel Formula.pptxQMMS Lesson 2 - Using Excel Formula.pptx
QMMS Lesson 2 - Using Excel Formula.pptx
 
HCI Lesson 2 - Components of Human-Computer Interaction (HCI).pdf
HCI Lesson 2 - Components of Human-Computer Interaction (HCI).pdfHCI Lesson 2 - Components of Human-Computer Interaction (HCI).pdf
HCI Lesson 2 - Components of Human-Computer Interaction (HCI).pdf
 
HCI Lesson 1 - Introduction to Human-Computer Interaction.pdf
HCI Lesson 1 - Introduction to Human-Computer Interaction.pdfHCI Lesson 1 - Introduction to Human-Computer Interaction.pdf
HCI Lesson 1 - Introduction to Human-Computer Interaction.pdf
 
DS Lesson 2 - Subsets, Supersets and Power Set.pdf
DS Lesson 2 - Subsets, Supersets and Power Set.pdfDS Lesson 2 - Subsets, Supersets and Power Set.pdf
DS Lesson 2 - Subsets, Supersets and Power Set.pdf
 
ITSP Lesson 6 - Information Privacy.pdf
ITSP Lesson 6 - Information Privacy.pdfITSP Lesson 6 - Information Privacy.pdf
ITSP Lesson 6 - Information Privacy.pdf
 
ITSP Lesson 5 - Intellectual Property Rights.pdf
ITSP Lesson 5 - Intellectual Property Rights.pdfITSP Lesson 5 - Intellectual Property Rights.pdf
ITSP Lesson 5 - Intellectual Property Rights.pdf
 
ITSP Lesson 1 - Ethics and Ethical Theories.pdf
ITSP Lesson 1 - Ethics and Ethical Theories.pdfITSP Lesson 1 - Ethics and Ethical Theories.pdf
ITSP Lesson 1 - Ethics and Ethical Theories.pdf
 
ITSP Lesson 1 - Ethics and Ethical Theories.pdf
ITSP Lesson 1 - Ethics and Ethical Theories.pdfITSP Lesson 1 - Ethics and Ethical Theories.pdf
ITSP Lesson 1 - Ethics and Ethical Theories.pdf
 
Animation Lesson 4 - Tools and Equipment in Animation.pdf
Animation Lesson 4 - Tools and Equipment in Animation.pdfAnimation Lesson 4 - Tools and Equipment in Animation.pdf
Animation Lesson 4 - Tools and Equipment in Animation.pdf
 
DSA Lesson 1 - Introduction to Data Structures.pdf
DSA Lesson 1 - Introduction to Data Structures.pdfDSA Lesson 1 - Introduction to Data Structures.pdf
DSA Lesson 1 - Introduction to Data Structures.pdf
 
Java Programming - Conditional Statements (Switch).pdf
Java Programming - Conditional Statements (Switch).pdfJava Programming - Conditional Statements (Switch).pdf
Java Programming - Conditional Statements (Switch).pdf
 
Animation Lesson 3 - Occupational Health and Safety Procedures.pdf
Animation Lesson 3 - Occupational Health and Safety Procedures.pdfAnimation Lesson 3 - Occupational Health and Safety Procedures.pdf
Animation Lesson 3 - Occupational Health and Safety Procedures.pdf
 
Animation Lesson 2 - Environment and Market (Updated).pdf
Animation Lesson 2 - Environment and Market (Updated).pdfAnimation Lesson 2 - Environment and Market (Updated).pdf
Animation Lesson 2 - Environment and Market (Updated).pdf
 
Animation Lesson 3 - Occupational Health and Safety Procedures.pdf
Animation Lesson 3 - Occupational Health and Safety Procedures.pdfAnimation Lesson 3 - Occupational Health and Safety Procedures.pdf
Animation Lesson 3 - Occupational Health and Safety Procedures.pdf
 
Personal Entrepreneurial Competencies (PECs).pdf
Personal Entrepreneurial Competencies (PECs).pdfPersonal Entrepreneurial Competencies (PECs).pdf
Personal Entrepreneurial Competencies (PECs).pdf
 
Environment and Market.pdf
Environment and Market.pdfEnvironment and Market.pdf
Environment and Market.pdf
 
Lesson 4 - Data and Variables.pdf
Lesson 4 - Data and Variables.pdfLesson 4 - Data and Variables.pdf
Lesson 4 - Data and Variables.pdf
 
Lesson 3 - Displaying Text on Screen.pdf
Lesson 3 - Displaying Text on Screen.pdfLesson 3 - Displaying Text on Screen.pdf
Lesson 3 - Displaying Text on Screen.pdf
 

Recently uploaded

“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
Muhammad Subhan
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
Wonjun Hwang
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 

Recently uploaded (20)

Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistan
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 

DSA Lesson 2 - Algorithm and Flowcharting.pdf

  • 1. ALGORITHM AND FLOWCHARTING Lesson 2 – Data Structures and Algorithm MR. ROWELL L. MARQUINA IT Instructor, PUP Biñan
  • 3. 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. IMAGE SOURCE: https://imgbin.com/png/uxvDNRys/computer-programming-computer-icons-technology-algorithm-png https://www.flaticon.com/free-icon/coding_1085774 ▪ 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.
  • 4. 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.
  • 5. 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.
  • 7. What is a Flowchart? A flowchart is a diagram that illustrates a process, system or computer algorithm. IMAGE SOURCE: https://www.frevvo.com/blog/wp-content/uploads/2021/10/image5-2.png Flowcharts are widely used in multiple fields for the purpose of: ▪ documentation ▪ planning ▪ analysis ▪ presentation
  • 8. Flowchart Symbols The American National Standards Institute (ANSI) set standards for flowcharts and their symbols in the 1960s. 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 In 1970 the International Organization for Standardization (ISO) adopted the ANSI symbols as the international standard for developing flowcharts.
  • 10. Flowchart Symbols NAME OF SYMBOL SYMBOL FUNCTION Terminal Symbol Indicates the beginning and end of the flowchart. Flowline Symbol Its shows the process’ direction or the next steps in the process. Process Symbol It shows the process or operations to be carried out by the program Decision Symbol It shows the step that contains a control mechanism or decision. Input/Output Symbol It indicates the process of getting data from the user or displaying data on screen.
  • 11. 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.
  • 12. START birthyear, age display “Enter Year of Birth:” input birthyear age = 2023 - birthyear display age END The program is initiated. The variables birthyear and age were introduced to the program. The program displays the instruction “Enter Year of Birth: ” on the screen. The program get an input from the user and store its value in the variable birthyear. The program computes for the value of age using the formula age = 2023 - birthyear. The program displays the value of age on the screen. The program is terminated.
  • 13. 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.
  • 14. START kilo, pound display “Enter Weight in Kilogram:” input kilo pound = kilo * 2.2 display pound END The program is initiated. The variables kilo and pound were introduced to the program. The program displays the instruction “Enter Weight in Kilogram: ” on the screen. The program get an input from the user and store its value in the variable kilogram. The program computes for the value of pound using the formula pound = kilo * 2.2. The program displays the value of pound on the screen. The program is terminated.
  • 15. 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.
  • 16. START length, width, area display “Enter Length:” input length The program is initiated. The variables length, width, and area were introduced to the program. The program displays the instruction “Enter Length: ” on the screen. The program get an input from the user and store its value in the variable length. The program displays the instruction “Enter Width: ” on the screen. The program get an input from the user and store its value in the variable width. The program will be continued on the next slide. display “Enter Width:” input width A
  • 17. area = length * width display area The program is continued. The program computes for the value of area using the formula area = length*width. The program displays the value of area on the screen. The program is terminated. A END
  • 18. 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
  • 19. START num1, num2, num3, num4, sum, product, square display “Enter the First Number: ” input num1 The program is initiated. The variables num1, num2, num3, num4, sum, product, and square were introduced to the program. The program displays the instruction “Enter the First Number: ” on the screen. The program get an input from the user and store its value in the variable num1. The program displays the instruction “Enter the Second Number: ” on the screen. The program get an input from the user and store its value in the variable num2. The program will be continued on the next slide. display “Enter the Second Number: ” input num2 A
  • 20. display “Enter the Third Number: ” input num3 The program is continued. The program displays the instruction “Enter the Third Number: ” on the screen. The program get an input from the user and store its value in the variable num3. The program displays the instruction “Enter the Fourth Number: ” on the screen. The program get an input from the user and store its value in the variable num4. The program will be continued on the next slide. display “Enter the Fourth Number: ” input num4 B A sum = num1 + num2 The program computes for the value of sum using the formula sum = a + b.
  • 21. display sum The program is continued. The program is terminated. display square B product = num3 * num4 The program computes for the value of product using the formula product = num3*num4. square = num2 * num2 display product END The program computes for the value of square using the formula square = num2 * num2. The program displays the value of sum on the screen. The program displays the value of product on the screen. The program displays the value of square on the screen.
  • 22. 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
  • 23. START num1, num2, num3, num4, cube, half, twentyp, times100 display “Enter the First Number: ” input num1 The program is initiated. The variables num1, num2, num3, num4, cube, half, twentyp, and times100 were introduced to the program. The program displays the instruction “Enter the First Number: ” on the screen. The program get an input from the user and store its value in the variable num1. The program displays the instruction “Enter the Second Number: ” on the screen. The program get an input from the user and store its value in the variable num2. The program will be continued on the next slide. display “Enter the Second Number: ” input num2 A
  • 24. display “Enter the Third Number: ” input num3 The program is continued. The program displays the instruction “Enter the Third Number: ” on the screen. The program get an input from the user and store its value in the variable num3. The program displays the instruction “Enter the Fourth Number: ” on the screen. The program get an input from the user and store its value in the variable num4. The program will be continued on the next slide. display “Enter the Fourth Number: ” input num4 B A cube = num1 * num1 * num1 The program computes for the value of cube using the formula cube = num1 * num1 * num1.
  • 25. The program is continued. The program is terminated. B half = num2 / 2 The program computes for the value of half using the formula half = num2 / 2. twentyp = num3 * 0.20 END The program computes for the value of twentyp using the formula twentyp = num3 * 0.20. The program displays the value of cube on the screen. The program displays the value of half on the screen. The program displays the value of twentyp on the screen. times100 = num4 * 100 display cube display half display twentyp display times100 The program computes for the value of times100 using the formula times100 = num4 * 100. The program displays the value of times100 on the screen.
  • 26. 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
  • 27. 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.
  • 28. 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 by 5.
  • 29. ALGORITHM AND FLOWCHARTING MR. ROWELL L. MARQUINA Professional Lecturer, Polytechnic University of the Philippines Email Address: rowell.marquina001@deped.gov.ph sirrowellmarquina@gmail.com rmarquina@mitis.edu.ph