Putational Problem
Putational Problem
Solving
CS001L.Module 1
First Term 2021 -2022
Mind Settings
Learning Understand the concepts and principles of Topic
Objective Process of Computational
computing including its history, application, Outline
benefits and costs in organizations and Problem Solving :
society.
Discover and apply the different models or # Problem Analysis, Design,
paradigms of computing.
Implementation, and Testing
Pattern Recognition
Abstraction
Algorithmic Thinking
5 Steps in Problem Solving Process
01 02 03 04 05
Understand Plan Code Test Production
Understanding the Plan the Logic Coding the Program Testing the Program Putting Program
Problem into
Production
5 Steps in Problem Solving Process
Remember: Failure to analyze and understand the requirements leads to a failed solution!
Understanding the
Problem
5 Steps in Problem Solving Process
Plan the steps that the program will take
02 Use tools such as flowcharts and pseudocode
Plan
Flowchart: a pictorial representation of the logic steps
Pseudocode: Natural language representation of the
logic
Walk through the logic before coding by desk-
checking the logic.
Plan the Logic
5 Steps in Problem Solving Process
• Coding is one of the most tedious parts in programming.
• Programmers choose a particular language because some
03 languages have built-in capabilities to make them more
Code efficient than others at handling certain types of operations.
PSEUDO = FALSE
A program means to put in a
CODE =
programming language
RULES FOR PSEUDOCODE
• The pseudocode must be language independent. Show
key words in CAPITAL LETTERS.
Example: IF condition THEN
DO action
ENDDO
ENDIF
• Indent lines to make the pseudocode easy to read and
understand.
RULES FOR PSEUDOCODE
• Punctuation is optional.
• Every IF must end with an ENDIF.
• Every DO, DO FOR and DO WHILE must end with
ENDDO.
• The main routine (the one that goes from START to
STOP) has to be shown first. All other routines are to
follow.
ADVANTAGES IN USING
PSEUDOCODE
• It bridges the gap between human language and
computer language.
• It is an intermediate notation that allows expression of
program logic in a straight forward, easy to
understand manner without concerning the
programmer with syntax details.
• It is easier to make changes to pseudocode than to a
source program in a high-level language.
RECIPE FOR SMALL SPONGE CAKES
Method:
• SET oven at 180oC.
• FOLLOW Method for Egg Sponge from Step a to d
• PLACE mixture in patty pans, half filling each one.
• BAKE at 180oC for approximately 10 minutes.
• COOL on cake cooler.
• CUT and FILL with whipped cream.
PASTILLAS RECIPE
• Procedures:
1. PLACE the condensed milk in a large mixing bowl.
2. GRADUALLY FOLD-IN the powdered milk. The texture of the
mixture will be similar to dough once all the powdered milk is
completely added.
3. SCOOP some of the mixture and mold into cylinders.
4. ROLL each molded cylindrical mixture on granulated sugar.
5. WRAP in paper or cellophane.
6. SERVE for dessert. Share and enjoy!
Example. Problem 1. We want to be able to enter the ages of two people
and have the computer calculate their average age and display the answer.
1 exit
1 entry, 2 exits
1 entry, 1 exit 1 entry, 1exit
Guidelines for Developing Flowchart
• Logical order • General flow of processes is top to
bottom or left to right.
• Flowchart can have only one (1)
start and one (1) end symbol. • Arrows should not cross each
other.
• On-page connectors are referenced
using numbers. • No ambiguity
• Off-page connectors are • Validity of the flowchart with a
referenced using alphabets. simple test data.
Three Building Blocks of an Algorithm
• Sequential: An algorithm is a step-by-step process, and
the order of those steps are crucial to ensuring the
correctness of an algorithm.
• Selection: Algorithms can use selection to determine a
different set of steps to execute based on a Boolean
expression.
• Iteration: Algorithms often use repetition to execute
steps a certain number of times or until a certain
condition is met.
START
SEQUENTIAL
Sum=0 START
Product=0
Sum=0
Sum = A + B
Print Sum, Product
Print Sum, Product = A * B
Product
END
END
SELECTION
START
Name = “ ”
START Remarks = “ “
T
Is Print A,
A>B? “Higher”
Is
Grade Remarks=”Passed”
F >= 60
Print B,
“Higher” END
Print Name,
Remarks=”Failed” Grade,
Remarks
END
REPETITION START
START
Pi=3.1416
C=0
R=1
AreaCircle = Pi * R * R
C < 10 END
Print R,
C =C + 1 AreaCircle
Print C
R <= 5 END
MODULE 1: Review Activity
Instructions: Solve for the following problem.
Construct a Flowchart showing the program logic.
1. Problem: Calculate the area of a rectangle.
BEGIN
READ LENGHT, width
areaRec = length X width
DISPLAY areaRec
END
2. Problem: calculate a person’s age.
BEGIN
ENTER BIRTH_year
Age = current_year – birth_year
PRINT AGE
END
3. Problem: calculate a person’s age with conditions.
BEGIN
READ age
IF (age is greater than 60)
PRINT “Senior Citizen”
ELSE
PRINT “Not Senior Citizen”
ENDIF
END
4. Problem: Read a test score and identify if the test score is passing
or try again. BEGIN
READ score
IF(score is greater
than or equal to 75)
print “Passed”
ELSE
PRINT “Try Again”
END
END
5. Problem: Write a program that reads and displays the age of 10 people (one after another).
START
SET users = 1
WHILE(users <= 10)
READ age
PRINT age
users = users + 1
EndWhile
END
Merci!
Any questions?
You may send your question in MS Teams
[email protected]
44
Computational Problem
Solving
CS001L.Module 1
First Term 2021 -2022