0% found this document useful (0 votes)
69 views7 pages

Algo at Pseudo

An algorithm is a set of well-defined steps to solve a problem or achieve a goal. It should have clear inputs and outputs, unambiguous steps, and be an effective way to solve the problem. Flowcharts and pseudocode are tools used to develop algorithms by representing the steps graphically or in plain language. Activity diagrams are another modeling language that can help programmers develop algorithms using symbols like actions, decisions, and transitions to show the workflow.
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)
69 views7 pages

Algo at Pseudo

An algorithm is a set of well-defined steps to solve a problem or achieve a goal. It should have clear inputs and outputs, unambiguous steps, and be an effective way to solve the problem. Flowcharts and pseudocode are tools used to develop algorithms by representing the steps graphically or in plain language. Activity diagrams are another modeling language that can help programmers develop algorithms using symbols like actions, decisions, and transitions to show the workflow.
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
You are on page 1/ 7

Algorithm

In programming, algorithm are the set of well defined instruction in sequence to solve a program.
An algorithm should always have a clear stopping point.
Qualities of a good algorithm
1. Inputs and outputs should be defined precisely.
2. Each steps in algorithm should be clear and unambiguous.
3. Algorithm should be most effective among many different ways to solve a problem.
4. An algorithm shouldn't have computer code. Instead, the algorithm should be written in such a way that, it can be
used in similar programming languages.

The algorithm is the basic technique used to get the job done. Let's follow an example to help get an understanding of the
algorithm concept.
Let's say that you have a friend arriving at the airport, and your friend needs to get from the airport to your house. Here
are four different algorithms that you might give your friend for getting to your home:
The taxi algorithm:
1. Go to the taxi stand.
2. Get in a taxi.
3. Give the driver my address.
The call-me algorithm:
1. When your plane arrives, call my cell phone.
2. Meet me outside baggage claim.
The rent-a-car algorithm:
1. Take the shuttle to the rental car place.
2. Rent a car.
3. Follow the directions to get to my house.
The bus algorithm:
1. Outside baggage claim, catch bus number 70.
2. Transfer to bus 14 on Main Street.
3. Get off on Elm street.
4. Walk two blocks north to my house.
All four of these algorithms accomplish exactly the same goal, but each algorithm does it in completely different way. Each
algorithm also has a different cost and a different travel time. Taking a taxi, for example, is probably the fastest way, but
also the most expensive. Taking the bus is definitely less expensive, but a whole lot slower. You choose the algorithm
based on the circumstances.


What is a Flow Chart?
Flow Chart Defined
A flow chart is a graphical or symbolic representation of a process. Each step in the process is
represented by a different symbol and contains a short description of the process step. The flow chart
symbols are linked together with arrows showing the process flow direction.
Symbols Used In Flowchart
Different symbols are used for different states in flowchart, For example: Input/Output and decision
making has different symbols. The table below describes all the symbols that are used in making
flowchart
Symbol Purpose Description

Flow line
Used to indicate the flow of logic by connecting
symbols.

Terminal(Stop/Start) Used to represent start and end of flowchart.

Input/Output Used for input and output operation.

Processing
Used for airthmetic operations and data-
manipulations.

Desicion
Used to represent the operation in which there
are two alternatives, true and false.

On-page Connector Used to join different flowline

Off-page Connector
Used to connect flowchart portion on different
page.

Predefined
Process/Function
Used to represent a group of statements
performing one processing task.

Different flow chart symbols have different meanings. The most common flow chart symbols are:
Terminator: An oval flow chart shape indicating the start or end of the process.
Process: A rectangular flow chart shape indicating a normal process flow step.
Decision: A diamond flow chart shape indication a branch in the process flow.
Connector: A small, labeled, circular flow chart shape used to indicate a jump in the process flow.
(Shown as the circle with the letter A, below.)
Data: A parallelogram that indicates data input or output (I/O) for a process.
Document: Used to indicate a document or report (see image in sample flow chart below)


Examples of flowcharts in programming
Draw a flowchart to add two numbers entered by user.

Draw flowchart to find the largest among three different numbers entered by user.


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
Print the class average.

3.
Initialize total to zero
Initialize counter to zero
Input the first grade
while the user has not as yet entered the sentinel
add this grade into the running total
add one to the grade counter
input the next grade (possibly the sentinel)
if the counter is not equal to zero
set the average to the total divided by the counter
print the average
else
print 'no grades were entered'

4.
initialize passes to zero
initialize failures to zero
initialize student to one
while student counter is less than or equal to ten
input the next exam result
if the student passed
add one to passes
else
add one to failures
add one to student counter
print the number of passes
print the number of failures
if eight or more students passed
print "raise tuition"

An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in
which to execute them.
Specifying the order in which statements (actions) execute in a program is called program control.
Pseudocode helps a programmer think out a program before attempting to write it in a programming
language.
Activity diagrams are part of the Unified Modeling Language (UML)an industry standard for modeling
software systems.
An activity diagram models the workflow (also called the activity) of a software system.
Activity diagrams are composed of special-purpose symbols, such as action state symbols, diamonds
and small circles. These symbols are connected by transition arrows that represent the flow of the
activity.
Like pseudocode, activity diagrams help programmers develop and represent algorithms.
An action state is represented as a rectangle with its left and right sides replaced with arcs curving
outward. The action expression appears inside the action state.
The arrows in an activity diagram represent transitions, which indicate the order in which the actions
represented by action states occur.
The solid circle located at the top of an activity diagram represents the initial statethe beginning of the
workflow before the program performs the modeled actions.
The solid circle surrounded by a hollow circle that appears at the bottom of the activity diagram
represents the final statethe end of the workflow after the program performs its actions.
Rectangles with the upper-right corners folded over are called notes in the UML. Notes are explanatory
remarks that describe the purpose of symbols in the diagram. A dotted line connects each note with the
element that the note describes.
A diamond or decision symbol in an activity diagram indicates that a decision is to be made. The
workflow will continue along a path determined by the symbol's associated guard conditions, which can
be true or false. Each transition arrow emerging from a decision symbol has a guard condition (specified
in square brackets next to the transition arrow). If a guard condition is true, the workflow enters the
action state to which the transition arrow points.

You might also like