1
CMSC 131 Fal 2009
Jan Plane (Adapted from Bonnie Dorr)
Lecture Set #13:
Algorithms and Design
1.
Algorithmic Design
2.
Algorithmic Analysis
3.
System Design
CMSC 131 Fal 2009
Jan Plane (Adapted from Bonnie Dorr)
1
What is an algorithm?
c
The method used to solve a particular problem is called an
algorithm
.
c
Example
: Make a peanut butter and jelly sandwich:
c
Get a loaf of bread
c
Remove two slices
c
Get a jar of peanut butter
c
Get a knife
c
Open the jar
c
Using the knife, get some peanut butter and spread it on one slice
c
…blah, blah, blah
c
There is essentially
one sequential process
being described.
CMSC 131 Fal 2009
Jan Plane (Adapted from Bonnie Dorr)
2
LowLevel Design:
PseudoCode and Algorithms
c
We have already talked about
pseudocode
as a
design technique
c
NOT English
c
NOT a program
c
Something inbetween
c
Captures the logic, flow of desired code
c
Note that pseudocode could be translated into any
programming language (not just Java)
c
Pseudocode is used to represent
algorithms
= step
bystep solutions to problems
c
Algorithms are often coded as single methods
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document2
CMSC 131 Fal 2009
Jan Plane (Adapted from Bonnie Dorr)
3
Concerns at the Algorithmic
Level of Design
c
Correctness
Does my algorithm correctly solve the problem?
c
Efficiency
Is my algorithm fast enough for the job?
c
Clarity
Is my algorithm understandable? and is it
implementable?
CMSC 131 Fal 2009
Jan Plane (Adapted from Bonnie Dorr)
4
Putting all your eggs in one
basket
c
Problem: I have 16 baskets full of 12 eggs each; I want
to “put all of my eggs in one basket”.
☺
c
Algorithm #1 ??
c
Combine #1 and #2
c
Combine result with #3
c
Combine result with #4; etc.
c
Algorithm #2 ??
c
Combine #1, #2; combine #3, #4; combine #5, #6…
c
Combine <1,2> with <3,4>; Combine <5,6> with <7,8>…
c
Combine <1,2,3,4> with <5,6,7,8>
c
Combine last two …
CMSC 131 Fal 2009
Jan Plane (Adapted from Bonnie Dorr)
5
Algorithmic Efficiency Analysis
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '08
 Plane
 Bonnie Dorr, Jan Plane

Click to edit the document details