[go: up one dir, main page]

0% found this document useful (0 votes)
22 views24 pages

Lesson 2

Uploaded by

jhegs tindugan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views24 pages

Lesson 2

Uploaded by

jhegs tindugan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

DIFFERENCE BETWEEN

ALGORITHM AND
PSEUDOCODE
COMPUTER PROGRAMMING I
Algorithm and Pseudocode are
the two related terms in
computer programming. The
basic difference between
algorithm and pseudocode is that
an algorithm is a step-by-step
procedure developed to solve a
problem, while a pseudocode is a
technique of developing an
algorithm.
In this article, we will discuss the
other important differences
between an algorithm and a
pseudocode. Let's start with some
basic concepts of algorithm and
pseudocode.
WHAT IS
ALGORITH
M?
7 TYPES OF
ALGORITHM
Brute Force Algorithm
A brute force algorithm is essentially trying all possibilities
until a result is found. It is the simplest and most basic
algorithm. Moreover, these types of algorithms allow for the
detection of the ideal or best solution, since they check all
possible solutions.
The method can also be used to find an acceptable solution
(not the best). Basically, it stops when an answer to the issue
has been found. A clear way to deal with a problem is the first
thing that comes to mind after observing a problem. This is the
main types of algorithms.
A sequence of steps to solve a given problem is called as algorithm.
Thus, an algorithm is a step-by-step procedure developed for solving a
given problem. An algorithm consists of sequences, iterations,
selections, etc. The selection of an algorithm depends upon the nature
of the given problem. Thus, the problem is first analyzed, and then the
best algorithm is used to solve it.
An algorithm follows a systematic and a logical approach, where the
procedure is defined step-wise. In an algorithm, many simple
operations are combined to help form a more complicated operation,
which is performed with ease by the computer.
Recursive Algorithm
Recursion is the key to this type of algorithm. A problem is
resolved by breaking it down into subproblems of a similar
nature and repeating the process over and over until it is
resolved with the help of a base condition.
Every time it recurs, it solves the base case legitimately and
then uses a more straightforward or simpler input. We use it to
handle issues that can be broken down into simpler or more
modest ones. It is also the main types of algorithms.
Dynamic Programming Algorithm
Algorithms of this type are also known as memoization techniques. As
a result, the thought is to keep track of the recently determined result
to avoid calculating it over and over again.
Using Dynamic Programming, you can break up the unpredictable issue
into smaller, more manageable subproblems and put the outcome
aside for later. We can say that it remembers previous results and uses
them to find new ones. it is the third main types of algorithms.
Divide And Conquer Algorithm
With the Divide and Conquer algorithm, the aim is to
tackle the issue in two sections, the first of which
divides the problem into subproblems that are similar
in nature. Second, we will approach the more modest
issue autonomously and then add the combined
outcome to complete our final response.
Greedy Algorithm
Next, we have a greedy algorithm, which creates the solution
portion by portion. In selecting the following role, it is
determined by the fact that it provides sudden help and that it
never considers the options that had been assumed recently.
Backtracking Algorithm
This type of algorithm seeks a steady solution to the issue by
eliminating solutions that fail to meet the requirements of the
issue at any moment. As an example, it is an algorithmic
procedure for handling issues recursively by attempting to
construct an answer steadily, eliminating solutions that fail to
meet the criteria at any moment.
Randomized Algorithm
During the computations, the algorithm uses a
random number at least once for deciding the
outcome. So, these are the main types of algorithms.
CHARACTERISTIC
S OF
ALGORITHM
There are some characteristics which every algorithm should
follow. There are five different characteristics which deal with
various aspects of algorithm. They are as follows:

1.Input specified
2.Output specified
3.Definiteness
4.Effectiveness
5.Finitness
6.Independent
1)Input specified
The input is the data to be transformed during the computation to produce
the output.An algorithm should have 0 or more well-defined inputs.Input
precision requires that you know what kind of data, how much and what form
the data should be,

2)Output specified
The output is the data resulting from the computation (your intended result).
An algorithm should have 1 or more well-defined outputs, and should match
the desired output.Output precision also requires that you know what kind of
data, how much and what form the output should be (or even if there
will be any output at all!).

3)Definiteness
Algorithms must specify every step and the order the steps must be taken in
the process.Definiteness means specifying the sequence of operations for
turning input into output. Algorithm should be clear and unambiguous.Details
of each step must be also be spelled out (including how to handle errors).It
should contain everything quantitative and not qualitative.
4)Effectiveness
For an algorithm to be effective, it
means that all those steps that are
required to get to output must be
feasible with the available resources.It
should not contain any unnecessary
and redundant steps which could make
an algorithm ineffective.
For example,suppose you are cooking
a recipe and you chop vegetables
which are not be used in the recipe
then it is a waste of time.
5)Finiteness
The algorithm must stop, eventually.Stopping may mean that
you get the expected output OR you get a response that no
solution is possible. Algorithms must terminate after a finite
number of steps.An algorithm should not be infinite and always
terminate after definite number of steps.
There is no point in developing an algorithm which is infinite as
it will be useless for us.

6)Independent
An algorithm should have step-by-step directions, which should
be independent of any programming code.It should be such
that it could be run on any of the programming languages.
Thus,these are the characteristics that an algorithm should
have for its fruitfulness.
The Common
Applications Of
Algorithms
In Computer Programming
If you want to solve a problem, you must first
develop an algorithm, no matter what
language you use. An algorithm flowchart
can help you solve even the most
complicated problems.
Say we are writing a program that prints
numbers from 1 to 20 automatically.
Whenever we run this program, we initialize
a variable and increment it by one. This
would be repeated until the number reaches
20.
Solving
Everyday
Problems
Algorithms can be used to solve almost
every problem, not just programming or
scientific problems. A recipe can be
derived from an algorithm, or tax can be
calculated using an algorithm.
Suppose you want to determine if a
student has failed or passed based on
their grades. You can use this flowchart
to grade your students in this case.
FLOWCHAR
T SHAPES
AND USES
FLOWCHART
SHAPES
AND USES
FOUR COMMON SYMBOLS
Flowcharts use special
shapes to represent
different types of actions or
FOUR steps in a process. Lines
and arrows show the
COMMON sequence of the steps, and
the relationships among

SYMBOLS
them. These are known as
flowchart symbols.

Rectangle Shape -
Represents a process
Oval or Pill Shape -
Represents the start or end
Diamond Shape -
Represents a decision

You might also like