0% found this document useful (0 votes)
7 views23 pages

01 Algorithm and Flowchart

The document provides an introduction to algorithms, defining them as step-by-step procedures for solving problems or performing computations. It outlines the properties and steps for designing algorithms, as well as the differences between algorithms and flowcharts. Additionally, it includes examples of algorithms and practice problems for implementation in Java.

Uploaded by

driencaballero
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)
7 views23 pages

01 Algorithm and Flowchart

The document provides an introduction to algorithms, defining them as step-by-step procedures for solving problems or performing computations. It outlines the properties and steps for designing algorithms, as well as the differences between algorithms and flowcharts. Additionally, it includes examples of algorithms and practice problems for implementation in Java.

Uploaded by

driencaballero
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

Intro to Computing and Algorithm

01

ALGORITHM AND
1010
010101
101010101

FLOWCHART
10101010101
01010101010101
10101010101010101
01010101010101010101
10101010101010101010101
Prepared by: MARIA AMORE DAYOT 01010101010101010101010101
0101010101010101010101010101
010101010101010101010101010101
1010101010101010101010101010101
1010101010101010101010101011010
1001010101010101010101010101010
10101010101010101010101010101
What is Algorithm?
An algorithm is a procedure used for solving a problem or
performing a computation. Algorithms act as an exact list of
instructions that conduct specified actions step by step in either
hardware- or software-based routines.

METRO DUMAGUETE COLLEGE, INC


Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
How do algorithms work?
Algorithms work by following a set of instructions or rules to
complete a task or solve a problem. They can be expressed as
• natural languages
• programming languages
• pseudocode
• flowcharts and control tables.

METRO DUMAGUETE COLLEGE, INC


Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
Therefore, an Algorithm refers to a sequence of finite steps to
solve a particular problem.

METRO DUMAGUETE COLLEGE, INC


Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
• Clear and Unambiguous: The algorithm should be unambiguous. Each of its steps should
be clear in all aspects and must lead to only one meaning.
• Well-Defined Inputs: If an algorithm says to take inputs, it should be well-defined
inputs. It may or may not take input.
• Well-Defined Outputs: The algorithm must clearly define what output will be yielded
and it should be well-defined as well. It should produce at least 1 output.
• Finite-ness: The algorithm must be finite, i.e. it should terminate after a finite time.
• Feasible: The algorithm must be simple, generic, and practical, such that it can be
executed with the available resources. It must not contain some future technology or
anything.
• Language Independent: The Algorithm designed must be language-independent, i.e. it
must be just plain instructions that can be implemented in any language, and yet the
output will be the same, as expected.
METRO DUMAGUETE COLLEGE, INC
Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
Properties of algorithm
• It should terminate after a finite time.
• It should produce at least one output.
• It should take zero or more input.
• It should be deterministic means giving the same output
for the same input case.
• Every step in the algorithm must be effective i.e. every
step should do some work.
METRO DUMAGUETE COLLEGE, INC
Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
Steps to design an algorithm
• The problem that is to be solved by this algorithm i.e. clear
problem definition.
• The constraints of the problem must be considered while
solving the problem.
• The input to be taken to solve the problem.
• The output is to be expected when the problem is solved.
• The solution to this problem is within the given
constraints.

METRO DUMAGUETE COLLEGE, INC


Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
Example
Step-by-Step Algorithm (in words).
Example Algorithm: Check if a Number is Even or Odd
1. Start
2. Input a number
3. Check if the number is divisible by 2
4. If yes, display "Even number"
5. Otherwise, display "Odd number"
6. End

METRO DUMAGUETE COLLEGE, INC


Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
Java Program Implementation.
Example Algorithm: Check if a Number is Even or Odd

METRO DUMAGUETE COLLEGE, INC


Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
METRO DUMAGUETE COLLEGE, INC
Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
LET’S PRACTICE
Practice Problem: Positive, Negative, or Zero.
Create a Java program that asks the user to enter a number and
determines whether the number is positive, negative, or zero.

METRO DUMAGUETE COLLEGE, INC


Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
LET’S PRACTICE
Practice Problem: Positive, Negative, or Zero.
Create a Java program that asks the user to enter a number and determines
whether the number is positive, negative, or zero.
Answer:
1. Start
2. Input a number
3. If the number is greater than 0, display “Positive number”
4. Else if the number is less than 0, display “Negative number”
5. Else, display “Zero”
6. End
METRO DUMAGUETE COLLEGE, INC
Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
METRO DUMAGUETE COLLEGE, INC
Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
FLOWCHART
A flowchart is a graphical representation of an algorithm.
Programmers often use it as a program-planning tool to solve a
problem. It makes use of symbols that are connected among
them to indicate the flow of information and processing. The
process of drawing a flowchart for an algorithm is known as
“flowcharting”.

METRO DUMAGUETE COLLEGE, INC


Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
METRO DUMAGUETE COLLEGE, INC
Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
METRO DUMAGUETE COLLEGE, INC
Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
METRO DUMAGUETE COLLEGE, INC
Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
METRO DUMAGUETE COLLEGE, INC
Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
METRO DUMAGUETE COLLEGE, INC
Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
METRO DUMAGUETE COLLEGE, INC
Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
METRO DUMAGUETE COLLEGE, INC
Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
Difference between algorithm and flowchart:

S. No Algorithm Flowchart
An algorithm is a step-by-step procedure to A flowchart is a diagram created with different
1
solve a problem. shapes to show the flow of data.
2 The algorithm is complex to understand. A flowchart is easy to understand.

3 In the algorithm, plain text is used. In the flowchart, symbols/shapes are used.

4 The algorithm is easy to debug. A flowchart is hard to debug.

5 The algorithm is difficult to construct. A flowchart is simple to construct.

6 The algorithm does not follow any rules. The flowchart follows rules to be constructed.
The algorithm is the pseudo-code for the A flowchart is just a graphical representation of
7
program. that logic.
METRO DUMAGUETE COLLEGE, INC
Ej. Blanco Extension Road, Brgy. Daro, Dumaguete city, Philippines 6200
Telephone Nos. (035) 420-9801, 420-9728 or 422-4605
Website: [Link]
END OF PRESENTATION 01
1010
010101

THANK YOU !!!


101010101
10101010101
01010101010101
10101010101010101
01010101010101010101
10101010101010101010101
Ej. Blanco Extension Road, Brgy. Daro,
Dumaguete city, Philippines 6200
EMAIL HERE 01010101010101010101010101
+63 000 0000 0000

0101010101010101010101010101
010101010101010101010101010101
1010101010101010101010101010101
1010101010101010101010101011010
1001010101010101010101010101010
10101010101010101010101010101

You might also like