0% found this document useful (0 votes)
6 views10 pages

Understanding Algorithms and Flowcharts

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views10 pages

Understanding Algorithms and Flowcharts

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

Common questions

Powered by AI

Different symbols in flowcharts represent various kinds of actions and elements in a process, aiding clear communication of a process's logic. The Terminal Symbol (oval) indicates the start and end of a process; the Input/Output Symbol (parallelogram) signifies actions related to input and output operations; the Processing Symbol (rectangle) stands for computational or processing steps; the Decision Symbol (diamond) marks points where the process can take multiple paths, and the Preparation Symbol (hexagon) is used for modifying the program’s flow, indicating control operations. Thus, these symbols illustrate the flow and decisions within processes, enhancing understanding and documentation .

Pseudocode can guide improvements in a software design process by allowing developers to outline the logical structure and flow before coding begins. For instance, when designing a program to calculate the area of a rectangle, pseudocode enables the identification of necessary steps—receiving inputs like length and width, performing arithmetic operations to determine the area, and outputting the result. By refining this outline to optimize variable assignments and computational steps, developers can identify potential efficiencies or issues early on, improving the software architecture and facilitating implementation in the actual coding phase .

A divide-and-conquer strategy might be less effective in scenarios where problems do not naturally decompose into smaller independent sub-problems, or when each sub-problem still requires as much computational resource as the original. Additionally, if the overhead of combining the solutions from sub-problems is too high, it may negate the efficiency gained from dividing them into smaller parts. This strategy is less suitable for problems requiring significant interaction between sub-problems or when a simpler iterative approach may suffice .

The preparation symbol in a flowchart plays the role of representing instructions or groups of instructions that alter or modify a program's execution path. It is necessary for scenarios where specific operations like initialization, control setting, or loop indication require explicit denotation to modify the flow of the process. This symbol ensures that flowcharts can adapt to requisite changes, such as variable resets or iterations, reflecting the dynamic aspects of comprehensive system designs .

Decision symbols in flowcharts contribute to processing logic and outcomes by denoting points where multiple paths can be taken based on conditional logic. At these junctures, the path to follow is determined by evaluating conditions, allowing for branching and iterative structures in program logic. This ability to depict conditional decisions ensures that processing flows are not linear and that the resultant outcomes depend precisely on variable evaluations and comparisons at each decision point, thus leading to dynamically correct outcomes .

Flow direction indicators are critical in complex flowcharts because they prevent confusion regarding the sequence and logic flow of processes, especially in layouts where routine top-to-bottom or left-to-right arrangements do not suffice. Arrowheads show the direction of data flow and processing, ensuring clarity in the reading order. When sequences are not straightforward, such as when logic flows right to left or bottom to top, arrowheads and flow lines guide the observer, ensuring the steps and decisions are followed in the intended order, thus maintaining the logical integrity of the process .

The Input-Process-Output (IPO) model comprises three main components: input, process, and output. The 'input' involves gathering the necessary data required to resolve a problem. The 'process' involves the computation or manipulation of the input data to generate a solution, and the 'output' involves presenting the results of the computation. Thus, these components work together by first collecting which parameters need consideration, applying a series of logical or arithmetic operations on these parameters, and finally producing a visible or tangible result .

A flowchart enhances understanding and documentation over written descriptions by providing a visual representation of an algorithm or process, which is often easier to comprehend. Labeled geometrical symbols such as ovals, diamonds, and rectangles in a flowchart visually communicate step-by-step operations and logic flows. This format is intuitive, allowing individuals to grasp complex ideas swiftly without sifting through extensive textual information. Consequently, flowcharts serve in effective communication, aiding both interpretation and instruction for process implementation .

Pseudocode facilitates the software development process by providing a high-level outline of a program without getting bogged down in the syntax details of actual coding, thus making it easier to understand and communicate algorithms. It features a simple, structured language that can easily be translated into real programming statements and typically includes actions such as the initialization and assignment of variables, and arithmetic and relational operations. These features allow developers to plan the logic and structure of a program before getting into coding, making the developmental process more efficient and organized .

The divide-and-conquer algorithm optimizes problem-solving by breaking a complex problem into more manageable sub-problems of the same or related type, solving each sub-problem recursively, and then combining the solutions of the sub-problems to solve the original problem. Its main steps include: 1) Divide, which involves breaking the primary problem into smaller parts; 2) Conquer, which involves solving each smaller problem recursively until they are simple enough to address directly; 3) Combine, which entails merging the solutions of sub-problems to form a complete solution to the original problem .

You might also like