the origins of “algorithm”. the origins of the term “algorithm”

13
The Origins of “Algorithm”

Post on 21-Dec-2015

239 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: The Origins of “Algorithm”. The Origins of the Term “Algorithm”

The Origins of “Algorithm”

Page 2: The Origins of “Algorithm”. The Origins of the Term “Algorithm”

The Origins of the Term “Algorithm”

Page 3: The Origins of “Algorithm”. The Origins of the Term “Algorithm”

Developing Algorithm Using Stepwise Refinement

• Read the problem statement carefully

• Rewrite it in your own words if it is not clear

• Highlight the nouns and look for data items

• Highlight the verbs to determine the work that needs to be done

• Write the initial algorithm that just describes the inputs, outputs and work to be done

Page 4: The Origins of “Algorithm”. The Origins of the Term “Algorithm”

Stepwise Refinement

• Now go back to each step in the initial algorithm and refine it to describe how it will be implemented

• The Key steps are:

• Rewrite the statement if not clear

• Nouns==>Data, Verbs==>Action

• Initial Algorithm(WHAT)

• Final Algorithm(HOW)

Page 5: The Origins of “Algorithm”. The Origins of the Term “Algorithm”

Algorithm Development Exercise

• Problem 1

• A Sunoco gas station offers 5 cents per gallon discount each Sunday. If a person fills up 20 gallons every week, how much money will that person save in X weeks?

Page 6: The Origins of “Algorithm”. The Origins of the Term “Algorithm”

Algorithm Development Exercise

• Problem 2

• Given the radius of a circle, develop an algorithm that computes the area and circumference

Page 7: The Origins of “Algorithm”. The Origins of the Term “Algorithm”

Algorithm Development Exercise

• Problem 3

• Write a cash register algorithm that will compute 7 percent sales tax at the price of an item and then add the tax to the price to obtain the final price

Page 8: The Origins of “Algorithm”. The Origins of the Term “Algorithm”

Properties of Algorithms

• Simplicity

• Precision

• Various Levels of Abstraction

Page 9: The Origins of “Algorithm”. The Origins of the Term “Algorithm”

Algorithms

• Algorithms specify the “behavior”

• Programs in specific languages just express the algorithm in one particular form

Page 10: The Origins of “Algorithm”. The Origins of the Term “Algorithm”

Information

• Information means knowledge about something

• Data is a specific representation of information

Page 11: The Origins of “Algorithm”. The Origins of the Term “Algorithm”

Components of An Algorithm

• Data Structures

• Data Manipulation Instructions

• Conditional Expressions

• (if price greater than my_limit then don’t buy)

• Control Structures

• (while (condition) do statement

• Modules

Page 12: The Origins of “Algorithm”. The Origins of the Term “Algorithm”

Levels of Abstraction

• Details are HIDDEN if we use TOP DOWN approach to describe algorithms

• Example: Counting names that begin with ‘A’ in a list of names

Page 13: The Origins of “Algorithm”. The Origins of the Term “Algorithm”

Recap

• What is the advantage of hiding details at the initial level of algorithm development?

• What properties of an object must be known to us before we can use it?

• How can we make software reusable?

• How many types of statements can be part of an algorithm?