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

1.-Algorithm

An algorithm is a systematic method for solving problems, often represented through flowcharts, pseudocode, or the Input-Process-Output (IPO) model. The IPO model categorizes processes into input, processing, and output stages, exemplified by programs that compute sums or areas. Flowcharts visually depict the sequence of operations in an algorithm using various symbols to represent different types of actions.

Uploaded by

renzdarrendt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

1.-Algorithm

An algorithm is a systematic method for solving problems, often represented through flowcharts, pseudocode, or the Input-Process-Output (IPO) model. The IPO model categorizes processes into input, processing, and output stages, exemplified by programs that compute sums or areas. Flowcharts visually depict the sequence of operations in an algorithm using various symbols to represent different types of actions.

Uploaded by

renzdarrendt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Algorithm - In mathematics and computer science, an algorithm is a step-by-step procedure to

solve a problem or to perform a task. One of the most obvious examples of an algorithm is a
recipe.

Ways to structure algorithms:

• Flowchart
• Pseudocode
• Divide and Conquer
• Input Process Output (IPO)

Input-Process-Output (IPO) model is a widely used approach in systems analysis and software
engineering for describing the structure of an information processing program or other process.

A computer program or any other sort of process using the input-process-output model
receives inputs from a user or other source, does some computations on the inputs, and returns
the results of the computations. The system divides the work into three categories:

• input - data that is needed to solve the problem


• process - the task that will be carried out to solve the problem
• output - the result of the problem

EXAMPLE 1
Compute the sum of three numbers, the program must:

 Ask the user for the three number (input)

 Perform a calculation to compute the sum (process)

 Display the sum (output)

A divide-and-conquer algorithm works by recursively breaking down a problem into two


or more subproblems of the same or related type, until these become simple enough to be
solved directly.
 Divide - break the given problem into smaller sub-problems.

 Conquer - Solve the smaller sub-problems. If the sub-problem is small enough, then solve it
directly.

 Combine - Merge the solutions of the sub-problems to get the solution to the actual or
original problem.
Pseudocode is an outline of a program, written in a form that can easily be converted into real
programming statements. It resembles the actual program that will be implemented later.
However, it cannot be compiled nor executed.

Pseudocode normally codes the following actions:

 Initialization of variables

 Assignment of values to the variables

 Arithmetic operations

 Relational operations
For example, a program might be written to compute the price of apples if the quantity in kg
and price per kg are given. The program must:

 Ask the user for the weight (quantity in kg) of apple and price per kilogram (input)

 Perform a calculation to compute the total price of apple (process)

 Display the total price (output)

a. Start

b. Read Quantity

c. Read PricePerKg

d. Price = Quantity * PricePerKg

e. Print Price

f. End

Compute the area of a rectangle, the program must:

 Ask the user for the length and width (input)

 Perform a calculation to compute the area (process)

 Display the area (output)

a. Start

b. Read Length

c. Read Width

d. Area = Length * Width

e. Print Area

f. End
Flowchart - A flowchart is a diagram representing the logical sequence in which a combination of
steps or operations is to be performed. It consists of labeled geometrical symbols that are
interconnected. It is also a visual representation of an algorithm. It is intended for communication
and documentation.

Terminal Symbol (oval) – use to designate the beginning and the end of the program.
Input/output Symbol (parallelogram) – represents an instruction to an input or an output device.

Processing Symbol (rectangle) – represent a group of program instructions that perform a


processing function of the program such as to perform arithmetic operations.

Decision Symbol (diamond) – denotes a point in the program where more than one path can be
taken.

Preparation Symbol (hexagon) – represent an instruction or group of instructions that will alter
or modify a program’s course of execution. It is commonly used to specify operations such as
control, index register, initialization, switch setting, and in indicating loops.

On-page Connector (small circle) – a none processing symbol use to connect one part of a
flowchart to another without drawing flow lines.

Off-page Connector (small pentagon) – to designate entry to or exit from a page when a flowchart
requires more than one page.

Flow Direction Indicators (arrowheads) – use to show the direction of processing or data flow.
These are added to flow lines if a flowchart appears confusing is its layout. Arrowheads are not
required when the logic flow is from top to bottom or from left to right.

Flow lines (horizontal/vertical lines) – use to show reading order or sequence in which flowchart
symbols are to be read. Flow lines are sometimes drawn with arrowheads. The commonly
accepted practice is to indicate an arrowhead if the logic flow is from right to left or from bottom
to top.

OPERATORS

EXAMPLE NO 1 – Make a flowchart that asks the weight of apple (kg) and its price per kilogram
and display the total.
EXAMPLE NO 2 – Make a flowchart that checks if a grade is passed or failed.
EXAMPLE WITH LOOP

You might also like