the origins of “algorithm”. the origins of the term “algorithm”
Post on 21-Dec-2015
239 views
TRANSCRIPT
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
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)
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?
Algorithm Development Exercise
• Problem 2
• Given the radius of a circle, develop an algorithm that computes the area and circumference
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
Properties of Algorithms
• Simplicity
• Precision
• Various Levels of Abstraction
Algorithms
• Algorithms specify the “behavior”
• Programs in specific languages just express the algorithm in one particular form
Information
• Information means knowledge about something
• Data is a specific representation of information
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
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
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?