Algorithm, Pseudocode, Flowchart What Is An Algorithm?
Algorithm, Pseudocode, Flowchart What Is An Algorithm?
Algorithm, Pseudocode, Flowchart What Is An Algorithm?
What Is an Algorithm?
Consider how you use a computer in a typical day. For example, you start working on a report,
and once you have completed a paragraph, you perform a spell check. You open up a spreadsheet
application to do some financial projections to see if you can afford a new car loan. You use a
web browser to search online for a kind of car you want to buy.
You may not think about this very consciously, but all of these operations performed by your
computer consist of algorithms. An algorithm is a well-defined procedure that allows a computer
to solve a problem. Another way to describe an algorithm is a sequence of unambiguous
instructions. The use of the term 'unambiguous' indicates that there is no room for subjective
interpretation. Every time you ask your computer to carry out the same algorithm, it will do it in
exactly the same manner with the exact same result.
Consider the earlier examples again. Spell checking uses algorithms. Financial calculations use
algorithms. A search engine uses algorithms. In fact, it is difficult to think of a task performed by
your computer that does not use algorithms.
How Do Algorithms Work?
Let's take a closer look at an example.
A very simple example of an algorithm would be to find the largest number in an unsorted list of
numbers. If you were given a list of five different numbers, you would have this figured out in no
time, no computer needed. Now, how about five million different numbers? Clearly, you are
going to need a computer to do this, and a computer needs an algorithm.
Here is what the algorithm could look like. Let's say the input consists of a list of numbers, and
this list is called L. The number L1 would be the first number in the list, L2 the second number,
etc. And we know the list is not sorted - otherwise the answer would be really easy. So, the input
to the algorithm is a list of numbers, and the output should be the largest number in the list.
The algorithm would look something like this:
Step 1: Let Largest = L1
This means you start by assuming that the first number is the largest number.
Step 2: For each item in the list:
This means you will go through the list of numbers one by one.
Step 3: If the itemLargest:
If you find a new largest number, move to step four. If not, go back to step two, which means you
move on to the next number in the list.
Step 4: Then Largest = the item
This replaces the old largest number with the new largest number you just found. Once this is
completed, return to step two until there are no more numbers left in the list.
Step 5: Return Largest
This produces the desired result.
An algorithm is a procedure for solving a problem in terms of the actions to be executed and the
order in which those actions are to be executed. An algorithm is merely the sequence of steps
taken to solve a problem. The steps are normally "sequence," "selection, " "iteration," and a casetype statement.
In C, "sequence statements" are imperatives. The "selection" is the "if then else" statement, and
the iteration is satisfied by a number of statements, such as the "while," " do," and the "for,"
while the case-type statement is satisfied by the "switch" statement.
Pseudocode is an artificial and informal language that helps programmers develop algorithms.
Pseudocode is a "text-based" detail (algorithmic) design tool.
The rules of Pseudocode are reasonably straightforward. All statements showing "dependency"
are to be indented. These include while, do, for, if, switch. Examples below will illustrate this
notion.
Examples:
1. If student's grade is greater than or equal to 60
Print "passed"
else
Print "failed"
2. Set total to zero
Set grade counter to one
While grade counter is less than or equal to ten
Input the next grade
Add the grade into the total
Set the class average to the total divided by ten
algorithms can be written in natural language, pseudocode is written in a format that is closely
related to high level programming language structures. But pseudocode does not use specific
programming language syntax and therefore could be understood by programmers who are
familiar with different programming languages. Additionally, transforming an algorithm
presented in pseudocode to programming code could be much easier than converting an
algorithm written in natural language.
FLOWCHARTS
A flowchart is a type of diagram that represents an algorithm, workflow or process, showing the
steps as boxes of various kinds, and their order by connecting them with arrows. This
diagrammatic representation illustrates a solution model to a given problem. Flowcharts are used
in analyzing, designing, documenting or managing a process or program in various fields
Flowcharts are used in designing and documenting complex processes or programs. Like other
types of diagrams, they help visualize what is going on and thereby help the people to understand
a process, and perhaps also find flaws, bottlenecks, and other less-obvious features within it.
There are many different types of flowcharts, and each type has its own repertoire of boxes and
notational conventions. The two most common types of boxes in a flowchart are:
A flowchart is described as "cross-functional" when the page is divided into different swimlanes
describing the control of different organizational units. A symbol appearing in a particular "lane"
is within the control of that organizational unit. This technique allows the author to locate the
responsibility for performing an action or making a decision correctly, showing the responsibility
of each organizational unit for different parts of a single process.
Symbol
Symbol Name
Flow Lines
Description
Used
to
connect
symbols
Terminal
Used to
represent start,
Input/Output
Represents
the
information
entering or
Processing
Represents
arithmetic
Decision
Represents a decision to
be made.
Connector
Used to
flow lines.
join different