Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: Algorithm and Data Structure
Description: Introduction to Algorithm and Data Structure

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


2/23/2015

ALGORITHMS AND FLOWCHARTS
A typical programming task can be divided into two
phases:
Problem solving phase
 produce an ordered sequence of steps that describe solution of
problem
 this sequence of steps is called an algorithm

Implementation phase

ALGORITHMS AND PROBLEM-SOLVING

STEPS IN PROBLEM SOLVING
First produce a general algorithm (one can use pseudocode)
Refine the algorithm successively to get step by step detailed
algorithm that is very close to a computer language
...
The final grade is calculated as the average of four
marks
...
Pseudocode is very similar to
everyday English
...

(Technical) A graphical representation of the sequence of operations in an
information system or program
...

Program flowcharts show the sequence of instructions in a single program or
subroutine
...


THE FLOWCHART
A Flowchart
 shows logic of an algorithm
 emphasizes individual steps and their interconnections
 e
...
control flow from one action to the next

2

2/23/2015

FLOWCHART SYMBOLS

EXAMPLE

Basic
Name

Oval

Symbol

START

Step 1: Input M1,M2,M3,M4
Step 2: GRADE = (M1+M2+M3+M4)/4
Step 3: if (GRADE <50) then
Print “FAIL”
else
Print “PASS”
endif

Use in Flowchart

Input
M1,M2,M3,M4

Denotes the beginning or end of the program

Parallelogram

Denotes an input operation

Rectangle

Denotes a process to be carried out
e
...
addition, subtraction, division etc
...

The program should continue along one of
two routes
...
g
...

Pseudocode:

Algorithm

START

Step 1: Input Lft

Input the length in feet (Lft)

Step 2:

Lcm = Lft x 30

Calculate the length in cm (Lcm) by multiplying LFT with 30

Step 3:

Print Lcm

Print length in cm (LCM)

Input
Lft

Lcm = Lft x 30

Print
Lcm

STOP

3

2/23/2015

EXAMPLE 3

EXAMPLE 3
Algorithm

Write an algorithm and draw a flowchart that will read the two
sides of a rectangle and calculate its area
...


Greater than or equal to




endif

ALGORITHM
Step 1: Input VALUE1, VALUE2
Step 2:

if (VALUE1 > VALUE2) then
MAX = VALUE1
else
MAX = VALUE2
endif

Step 3: Print “The largest value is”, MAX

6

2/23/2015

EXAMPLE 5

NESTED IFS
START

Input
VALUE1,VALUE2

Y

MAX

is
VALUE1>VALUE2

= VALUE1

MAX

One of the alternatives within an IF–THEN–ELSE statement
 may involve further IF–THEN–ELSE statement
N

= VALUE2

Print

“ The largest value is” ,
MAX
STOP

EXAMPLE 6

EXAMPLE 6
Step 1: Input

N1, N2, N3

Step 2: if (N1>N2) then
if (N1>N3) then

Write an algorithm that reads three numbers and prints the value of the largest
number
...


determine the bonus payment (PAYMENT)
Title: Algorithm and Data Structure
Description: Introduction to Algorithm and Data Structure