introduction to algorithm – part one jennifer elmer form 3 computing

Post on 20-Jan-2016

218 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Introduction to Algorithm – part one

Jennifer ElmerForm 3 Computing

What is an Algorithm?

An Algorithm is a step by step process to solve a computing problem.

StartStep 1Step 2Step 3Step 4Step…End

Process

What is a process?

A process is a series of steps (instructions) to achieve a particular goal

How can we express a solution in English language?

1. Think of a solution to the problem

2. Think of the steps required to achieve the final solution.

3. Write down the STEPS in English language.

What is Pseudo code?

Pseudo code is a way of expressing a computer solution algorithm similar to English language.

Example question

How do you log in to Facebook?Answer? Use a laptop, tablet, computer,

smart phone, etc.How do you write an algorithm to log in to

Facebook?1st step: Go to www.facebook.com2nd step: Enter email and password3rd step: Click on ‘Login in’ button.

An algorithm is constructed with Pseudo Code and Flowcharts

Pseudo Code Flowcharts

Step by step instructions similar to English language.

Diagram to represent the steps defined in pseudo code.

Pseudo code for Arithmetic calculations

Sum = A + BPrint SumHow many subjects there is in Sum?

Sum = A – BPrint SumHow many subjects there is in Sum?

Person A has 6 subjectsPerson B has 3 subjects

Pseudo code for Arithmetic calculations (input and output)

Give input value to ASave AGive input value to BSave BSum = A x BPrint Sum

What is the value of Sum?

A = 0; B = 0;

Flow Chart of Arithmetic calculation (input and output)

TasksConclusion Algorithm Topic first part

Conclusion

An algorithm is a step by step process to solve a computing problem.

A process is a series of steps or instructions to achieve a particular goal.

An algorithm can be developed through pseudo code and flowcharts.

Pseudo code defines the algorithm in a series of sequential steps/ instructions

Flowcharts express the steps of an algorithm in a diagram form. Each shape means a particular stage or step of an algorithm.

Introduction to Algorithm – part two

Jennifer ElmerForm 3 Computing

An algorithm is constructed with Pseudo Code and Flowcharts

Pseudo Code Flowcharts

Step by step instructions similar to English language.

Diagram to represent the steps defined in pseudo code.

Concept Flowchart

Flow Chart of Arithmetic calculation (input and output)

Mixer Flowchart – Decisions / Repetitions

Task 1Pseudo code of kitchen mixer

Task 2 – Flowchart to log in to Facebook

Pseudo Code:

1st step: Go to www.facebook.com2nd step: Enter email and password3rd step: Click on ‘Login in’ button.

Steps to make art coffee.

1. Put coffee with boiling water in the cup

2. Add steamed milk to the top of cup

Steps to make art coffee.

3. Make circular designs with chocolate sauce.

4. Draw inward and outward lines with a toothpick.

Steps to make art coffee.

End result – Web coffee art!

Pseudo Code If […] Then [….] Else [….] statements

Conditional statements

Pseudo Code for coffee art.

Start ProgramStep 1. If cup has coffee Then -> Add milkElse Add coffeeStep 2. If cup has coffee + milk Then -> Add chocolate sauce in circular motionElse go to step 1 Step 3. If cup has chocolate sauce on top Then -> make horizontal lines with toothpickElse go to step 2Step 4. End If Coffee has horizontal chocolate lines..Else go to step 3End program

Note: the conditional statements in red

Task 3Develop flowchart

Conclusion

An algorithm is a step by step process to solve a computing problem.

In computing an algorithm is expressed by pseudo code and flowcharts.

Pseudo code is constructed by writing a sequence of steps to solve a computing problem.

Flowcharts are used to show the sequence of steps in a diagram form using different shapes to present terminals, processes, decisions and inputs and outputs.

New task

Why an algorithm is usedHow can we construct a computing

solutionGive two tools used to develop an

algorithm

top related