introduction to algorithm – part one jennifer elmer form 3 computing

27
Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

Upload: arnold-sanders

Post on 20-Jan-2016

218 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

Introduction to Algorithm – part one

Jennifer ElmerForm 3 Computing

Page 2: Introduction to Algorithm – part one Jennifer Elmer Form 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

Page 3: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

What is a process?

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

Page 4: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

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.

Page 5: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

What is Pseudo code?

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

Page 6: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

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.

Page 7: Introduction to Algorithm – part one Jennifer Elmer Form 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.

Page 8: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

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

Page 9: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

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;

Page 10: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

Flow Chart of Arithmetic calculation (input and output)

Page 11: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

TasksConclusion Algorithm Topic first part

Page 12: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

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.

Page 13: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

Introduction to Algorithm – part two

Jennifer ElmerForm 3 Computing

Page 14: Introduction to Algorithm – part one Jennifer Elmer Form 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.

Page 15: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

Concept Flowchart

Page 16: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

Flow Chart of Arithmetic calculation (input and output)

Page 17: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

Mixer Flowchart – Decisions / Repetitions

Page 18: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

Task 1Pseudo code of kitchen mixer

Page 19: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

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.

Page 20: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

Steps to make art coffee.

1. Put coffee with boiling water in the cup

2. Add steamed milk to the top of cup

Page 21: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

Steps to make art coffee.

3. Make circular designs with chocolate sauce.

4. Draw inward and outward lines with a toothpick.

Page 22: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

Steps to make art coffee.

End result – Web coffee art!

Page 23: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

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

Conditional statements

Page 24: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

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

Page 25: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

Task 3Develop flowchart

Page 26: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

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.

Page 27: Introduction to Algorithm – part one Jennifer Elmer Form 3 Computing

New task

Why an algorithm is usedHow can we construct a computing

solutionGive two tools used to develop an

algorithm