Download presentation

Presentation is loading. Please wait.

Published byIra Arnold Modified over 2 years ago

1
Mathematics for Computing Lecture 4: Algorithms and flowcharts Dr Andrew Purkiss-Trew Cancer Research UK a.purkiss@mail.cryst.bbk.ac.uk

2
Algorithms An algorithm is a step-by-step set of instructions for solving a particular problem We will be using flowcharts to explore simple algorithms

3
Flowchart Graphical representation of an algorithm Show the ‘layout’ of a program Form is a series of symbols linked with arrows

4
Flowchart symbols 1 Terminator Data Entry (or Input/Output) Process

5
Flowchart Symbols 2 Decision Preparation Connector 1

6
Flowchart example 1 Find the mean of two numbers Start Read X,Y Sum = X+Y Mean = Sum / 2 Print Mean Stop

7
Flowchart example 2:1 Solve a quadratic equation ax 2 +bx+c = 0 Discriminant, D = b 2 -4ac, tells us how many real solutions. D <0 means no real solution, D=1 means 1 solution: x = -b/2a D>0 means 2 solns: x = -b ± √(b 2 – 4ac) 2a

8
Flowchart example 2:2 Start Read A,B,C D = B 2 -4xAxC Sign of D? 123 negative positive zero 123 Print ‘No real solution X = -B 2xA Print ‘solution’, X Stop X1 = -B + √D 2xA X2 = -B - √D 2xA Print X1, X2

9
Pseudocode Algorithms can also be represented as ‘English language’ instructions. These are then converted to the relevant program code.

12
Variables and Constants Variable Constants Numerical: Integer or exponential Non-numerical: Strings Logical: True or False

13
Flowchart Symbols Input / Output Process Decision Connector Preparation Terminal

Similar presentations

Presentation is loading. Please wait....

OK

Basic problem solving CSC 111.

Basic problem solving CSC 111.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on surface water pump Ppt on code switching and code mixing Ppt on ufo and aliens in california Ppt online compressor mechanic school Ppt on eddy current probe Ppt on energy giving food for kids Ppt on land resources and development Ppt on any one mathematician byron Compress ppt online free Ppt on council of ministers sudan