Title: The Algorithmic Model
1The Algorithmic Model
2The Algorithmic Model
- What is Computer Science
- What is Programming
- Algorithms
- Definition
- Properties of Good Algorithms
- Describing Algorithms
- Examples
- Components of Algorithms
3What is Programming
- Programming requires two skills
- Algorithmic thinking
- Knowledge of programming language syntax
- Learning language syntax is the easy part
4How We Learn Computer Science
- We use pseudo-code to focus on learning
algorithmic thinking - From there, you can go anywhere!
- Not using a computer to compile and run your
program forces you to mentally execute your
program and debug it! - Too many programmers try to program by brute
force and twiddling
5Algorithm Defined
- A set of logical steps to accomplish a task
- A recipe of action
- A way of describing behavior
- Algorithms contain
- Data
- Instructions
6Algorithms in Computing
Input Data Algorithm Output Data
7Algorithm Recipe
- Chocolate Chip Cookies DATA
(ingredients) 2 1/4 cups flour 1 tsp salt 1
tsp baking soda 2 eggs 3/4 cup brown sugar 1
tsp vanilla ext. 3/4 cup grand sugar 1 cup
soft butter 12oz. semi-sweet chocolate
chipsINSTRUCTIONS (steps) Preheat oven to
375. Combine flour, salt, baking soda, in
bowl, set mixture aside. Combine sugars,
butter, vanilla, beat until creamy. Add eggs
and beat. Add dry mixture and mix well.
Stir in chocolate chips Drop mixture by
teaspoons onto ungreased cookie sheet Bake 8
to 10 minutes
8Abstraction
- a general idea or term
- an impractical idea visionary and unrealistic
- general characteristics apart from concrete
realities, specific objects or actual instances - withdrawal
- absent-mindedness inattention
- a work of art stressing formal relationships
(Random House Dictionary of the English Language)
- In Computer Science
- Abstraction refers to the LOGICAL GROUPING of
concepts or objects - Define/implement the general idea, isolate the
details
9Abstraction in Algorithms
- The Abstraction
- Get to Clayton State IT Dept. from Atlanta
- One Implementation
- begin
- get on I-75 heading south
- exit I-75 onto exit 234
- turn left
- turn right on Clayton State Bvd.
- hit duck
- park in front of IT Dept.
- walk into front door
- end
- Other implementations of the same abstraction can
be just as correct, better, or worse
10Whats Wrong With This Algorithm?
(From back of shampoo bottle) Directions
Wet Hair Apply a small amount of shampoo
Lather Rinse Repeat
11Properties of Good Algorithms
- Good algorithms are
- Precise
- Unambiguous
- Complete
- Correct
- Simple
- Contain levels of abstraction
12Describing Algorithms
- Natural language (English)
- Pictures
- Pseudo-code or a specific programming language
13- Make a list of courses you want to register for,
in order of priority - Start with empty schedule. Number of hours 0.
- Choose highest priority class on list.
- If the chosen class is not full and its class
time does not conflict with classes already
scheduled, then register for the class - 4.a. Add the class to the schedule
- 4.b. Add the class hours to the number of hours
scheduled - Cross that class off of your list.
- Repeat steps 3 through 5 until the number of
hours scheduled is gt 15, or until all classes
have been crossed out. - Stop.
14Flowcharts
Begin
Make list of classes you want to take
Num Hours 0
Choose highest priority class on list
yes
Is this class full?
no
yes
Is there a time conflict?
no
Add the class to your schedule. Add class hours
to Num Hours.
Cross the class off your list.
yes
Num Hours gt 15?
no
yes
More classes on list?
no
15Components of Algorithms
- Any computing algorithm will have AT MOST five
kinds of components - Data structures to hold data
- Instructions change data values
- Conditional expressions to make decisions
- Control structures to act on decisions
- Modules to make the algorithm manageable by
abstraction, i.e., grouping related components
16FIN