Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax...
-
Upload
jody-skinner -
Category
Documents
-
view
215 -
download
0
Transcript of Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax...
![Page 1: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/1.jpg)
Announcements
Lab 9 and Project 2B instructions are posted on the calendar page Start early
Voting for Best Hoax Pages is up on the calendar page Due by Thursday, 10pm
Winners announced on Friday
2012-05-14 Katherine Deibel, Fluency in Information Technology 1
![Page 2: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/2.jpg)
Announcement: Extra Credit Attend the Undergraduate Research
Symposium this Friday Find a poster or talk relating to IT
Can be directly about IT
Maybe involves using IT Write a 200-word essay describing it
and how it relates to notions of fluency Worth up to 10 points
2012-05-14 Katherine Deibel, Fluency in Information Technology 2
![Page 3: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/3.jpg)
Algorithms More than just solving the problem
Fluency with Information Technology
2012-05-14 Katherine Deibel, Fluency in Information Technology 3
INFO100 and CSE100
Katherine Deibel
![Page 4: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/4.jpg)
1. A programming language is better for defining an algorithm than English is because …
A. B. C. D.
25% 25%25%25%A. Programming languages use fewer letters for code
B. English is ambiguousC. No difference, both are fineD. None of the above
2012-05-14 Katherine Deibel, Fluency in Information Technology 4
![Page 5: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/5.jpg)
Peanut Butter Sandwich Demo
You need to tell me how to make a peanut butter sandwich
2012-05-14 Katherine Deibel, Fluency in Information Technology 5
Please warn me if any of you have a severe peanut allergy
![Page 6: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/6.jpg)
Katherine Deibel, Fluency in Information Technology 6
The Point of that Little Fun
Human language has lots of cultural context and knowledge that influences understanding
Programming languages are very precise in describing what they do They have to be that way
2012-05-14
![Page 7: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/7.jpg)
2. To be an algorithm, a process must
A. B. C. D.
25% 25%25%25%
2012-05-14 Katherine Deibel, Fluency in Information Technology 7
A. Have its inputs specifiedB. Be effectiveC. FinishD. All of these
![Page 8: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/8.jpg)
3. A(n) ___ is a generalized method while a(n) ___ is a specialized solution.
A. B. C. D. E.
20% 20% 20%20%20%A. program, algorithmB. algorithm, programC. abstraction, algorithmD. abstraction, programE. none of these
2012-05-14 Katherine Deibel, Fluency in Information Technology 8
![Page 9: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/9.jpg)
What is an algorithm?
Algorithms are what computer scientists study
It's not just writing code!
2012-05-14 Katherine Deibel, Fluency in Information Technology 9
![Page 10: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/10.jpg)
Katherine Deibel, Fluency in Information Technology 10
What Computer Scientists Do
We solve problems EFFICIENTLY: Define what the problem is
What inputs are given? What needs to be solved? What needs to be outputted?
Develop a solution process Is it accurate? Is it efficient? Could we improve it?
Implementation How do we organize the data? Does the choice of software/hardware change
the efficiency?
2012-05-14
![Page 11: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/11.jpg)
Katherine Deibel, Fluency in Information Technology 11
Algorithms Everywhere
Theory All about algorithms
Graphics Even more algorithms
Architecture/Hardware Branch prediction, memory schemes, etc.
Networks Ensure transmission, data compression, etc.
Human-Computer Interaction Efficiency of human input/output
2012-05-14
![Page 12: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/12.jpg)
What is an algorithm?
"[An] algorithm is a procedure and sequence of actions to accomplish some task. The concept of an algorithm is often illustrated by the example of a recipe, although many algorithms are much more complex; algorithms often have steps that repeat (iterate) or require decisions (such as logic or comparison). In most higher level programs, algorithms act in complex patterns, each using smaller and smaller sub-methods which are built up to the program as a whole."
Source: Computer User's online dictionary
2012-05-14 Katherine Deibel, Fluency in Information Technology 12
![Page 13: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/13.jpg)
What is an algorithm?
Simply put:An algorithm is a precise description of the steps and methods used to solve a problem or produce a specified result
2012-05-14 Katherine Deibel, Fluency in Information Technology 13
![Page 14: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/14.jpg)
What is an algorithm?
Simply put:An algorithm is a precise description of the steps and methods used to solve a problem or produce a specified result
2012-05-14 Katherine Deibel, Fluency in Information Technology 14
![Page 15: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/15.jpg)
Properties of Algorithms
For an algorithm to be well specified, it must have the following
Inputs specified
Outputs specified
Definiteness
Effectiveness
Finiteness
Form of data to process
Form of results to produce
Agent always knows what to do next
Agent able to do all commands
Will stop with answer, or say ‘none’
2012-05-14 Katherine Deibel, Fluency in Information Technology 15
![Page 16: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/16.jpg)
Properties applied to a recipe
Title Ingredients (inputs) Steps
Exceptions
When to stop Servings (outputs)
2012-05-14 Katherine Deibel, Fluency in Information Technology 16
![Page 17: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/17.jpg)
Katherine Deibel, Fluency in Information Technology 17
Context Matters
Algorithms are abstract but how and where you execute them matters
Think about baking bread In an electric oven
Brick oven
A bread machine The recipes may need to
differ depending on the machine in use
2012-05-14
![Page 18: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/18.jpg)
Algorithms vs Programs
The recipe metaphor breaks down here Algorithms are abstract:
Not specific to any hardware
Not specific to any programming language
Programs are instantiations of algorithms Put into a specific language
Meant to work in specified contexts
2012-05-14 Katherine Deibel, Fluency in Information Technology 18
![Page 19: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/19.jpg)
Previous Algorithms
We have already seen several algorithms (and programs) Constructing a table of Fahrenheit to
Celsius conversions (Ch. 20)
Computing the price of espresso drink (Ch. 18)
Computing weight in gold
Fingerspelling (parsing of input)
2012-05-14 Katherine Deibel, Fluency in Information Technology 19
![Page 20: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/20.jpg)
Sorting AlgorithmsEveryday application
2012-05-14 Katherine Deibel, Fluency in Information Technology 20
![Page 21: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/21.jpg)
Elements of Sorting
Inputs specified:A list of items in any order
Outputs specified:The items in ascending order
Definiteness: Effectiveness: Finiteness:
Clearly can be done in finite time
2012-05-14 Katherine Deibel, Fluency in Information Technology 21
![Page 22: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/22.jpg)
Turn to your neighbor…
With your neighbor(s), discuss how you would sort a deck of cards into numerical order (As, 2s, 3s,…, Qs, Ks) How many different ways can you
think of? Is any better than the
others? How do you know?
2012-05-14 Katherine Deibel, Fluency in Information Technology 22
![Page 23: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/23.jpg)
Random Sort
Algorithm:Check if deck is sorted
If not sorted, shuffle the deck
Repeat Will it finish? Will it be correct? Is it efficient?
2012-05-14 Katherine Deibel, Fluency in Information Technology 23
![Page 24: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/24.jpg)
Insertion Sort
Algorithm:
Take first card and start a sorted pile
For each remaining card
Find the position where it belongs in the sorted pile
Place card in correct spot
2012-05-14 Katherine Deibel, Fluency in Information Technology 24
![Page 25: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/25.jpg)
Insertion Sort
Deck: 4, 7, 2, 5, J, 8, …
1. Deck: 4 | 7, 2, 5, J, 8, …
2. Deck: 4, 7 | 2, 5, J, 8, …
3. Deck: 2, 4, 7 | 5, J, 8, …
4. Deck: 2, 4, 5, 7 | J, 8, …
5. Deck: 2, 4, 5, 7, J | 8, …
6. Deck: 2, 4, 5, 7, 8, J | …
2012-05-14 Katherine Deibel, Fluency in Information Technology 25
![Page 26: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/26.jpg)
Insertion Sort
Does it end? Yes Will it be correct? Yes Is it efficient?
Fairly efficient in real world
Programming has varying performance:▪ Best: Linear O(n)
▪ Worst: Quadratic O(n2)
2012-05-14 Katherine Deibel, Fluency in Information Technology 26
![Page 27: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/27.jpg)
Merge Sort
Algorithm:
Split deck into two piles
Merge sort first pile
Merge sort second pile
Merge the two sorted piles This is a recursive function in that it
is continually applied to itself
2012-05-14 Katherine Deibel, Fluency in Information Technology 27
![Page 28: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/28.jpg)
Merge Sort Example
Deck: 3, 6, 7, 2, 1, 8, 4, 5,
1. 3, 6, 7, 2 | 1, 8, 4, 5 (split)
2. 3, 6 | 7, 2 | 1, 8, 4, 5 (split)
3. 3, 6 | 7, 2 | 1, 8, 4, 5 (sort left)
4. 3, 6 | 2, 7 | 1, 8, 4, 5 (sort right)
5. 2, 3, 6, 7 | 1, 8, 4, 5 (merge)
6. 2, 3, 6, 7 | 1, 8 | 4, 5 (split)
7. 2, 3, 6, 7 | 1, 8 | 4, 5 (sort left)
8. 2, 3, 6, 7 | 1, 8 | 4, 5 (sort right)
9. 2, 3, 6, 7 | 1, 4, 5, 8 (merge)
10. 1, 2, 3, 4, 5, 6, 7, 8 (merge)
2012-05-14 Katherine Deibel, Fluency in Information Technology 28
![Page 29: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/29.jpg)
Merge Sort
Does it end? Yes Will it be correct? Yes Is it efficient?
Fairly efficient in real world
Programming has consistent performance:
▪ Best: O(n log2 n)
▪ Worst: O(n log2 n)
▪ Worse than linear, better than quadratic
2012-05-14 Katherine Deibel, Fluency in Information Technology 29
![Page 30: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/30.jpg)
Many Sorting Algorithms
Multiple approaches for sorting Some more efficient in time in general
Some more efficient depending on nature of input
Examples of sorting performance:http://www.sorting-algorithms.com/
2012-05-14 Katherine Deibel, Fluency in Information Technology 30
![Page 31: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/31.jpg)
EncryptionKeeping Secrets via Algorithms
2012-05-14 Katherine Deibel, Fluency in Information Technology 31
![Page 32: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/32.jpg)
Katherine Deibel, Fluency in Information Technology 32
4. In public key cryptography
2012-05-14
A. B. C. D.
25% 25%25%25%A. The encryption scheme is kept secret
B. Multiple people are involved in the encryption process
C. Some parameters are shared openly
D. Is only used by the NSA
![Page 33: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/33.jpg)
Encryption / Decryption
Encrypt: Transform data so that it is no longer understandable
Decrypt: Transform encrypted data to be understandable again
2012-05-14 Katherine Deibel, Fluency in Information Technology 33
Encryption and decryptionare algorithms
![Page 34: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/34.jpg)
Caesar Ciper
Supposedly used by Julius Caesar Algorithm:
To encrypt:Move each letter n letters ahead
To decrypt:Move each letter n letters back
The movement wraps around the alphabet Y + 3 B
2012-05-14 Katherine Deibel, Fluency in Information Technology 34
![Page 35: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/35.jpg)
Caesar Ciper
Example when n = 5 A F
B G
…
M R
…
Y D
Z E
2012-05-14 Katherine Deibel, Fluency in Information Technology 35
N QNPJ HFYX
I LIKE CATS
![Page 36: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/36.jpg)
Katherine Deibel, Fluency in Information Technology 36
Caesar Cipher
Simple algorithm Easy to implement Easy to crack
Ever play a cryptogram?
The twelve most common letters in English (descending): ETAOIN SHRDLU
2012-05-14
![Page 37: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/37.jpg)
RSA
Public key cryptography system invented in 1978 by Ron Rivest, Adi Shamir, and Leonard Adleman
Before we get into the details… Are any of you international students?
Is it before 1999?
2012-05-14 Katherine Deibel, Fluency in Information Technology 37
![Page 38: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/38.jpg)
Katherine Deibel, Fluency in Information Technology 38
Encryption is a Munition
After WWII, encryption algorithms were deemed as military equipment Actually listed as munitions
Export to foreign countries tightly controlled Debates about teaching to international students
Richard White had the RSA algorithm tattooed on his arm and was theoretically unable to travel internationally
Printing and discussing of encryption algorithms is now recognized as free speech Bernstein (Pretty Good Privacy) v. United States
2012-05-14
![Page 39: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/39.jpg)
Back to RSA
The basics of RSA:
1. Pick two large prime numbers p and q
2. Compute n = pq, m = (p-1)(q-1)
3. Choose a number e such that 1 < e < m and e and m's only common divisor is 1
4. Calculate d = e-1 mod m
5. Publish n and e; d and m are kept private
Encryption of integer i: c = ie mod n
Decryption of integer c: i = cd mod m2012-05-14 Katherine Deibel, Fluency in Information Technology 39
![Page 40: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/40.jpg)
Katherine Deibel, Fluency in Information Technology 40
Makes sense, right?
RSA involves some fairly complex number theory
What you need to know Based on prime numbers
Factoring numbers into prime components is computationally difficult
Larger prime numbers make RSA really secure (but only 99.9999999% secure)
2012-05-14
![Page 41: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/41.jpg)
Public key systems
RSA is an example of a public key system The encryption involves a numerical
computation with several parameters Some parameters are shared (public keys)
Some parameters are not (private keys) Dominant form of encryption today
Scales by increasing the length of parameters
2012-05-14 Katherine Deibel, Fluency in Information Technology 41
![Page 42: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/42.jpg)
Building your own algorithmsSome tools
2012-05-14 Katherine Deibel, Fluency in Information Technology 42
![Page 43: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/43.jpg)
Solving a Large Problem
Large problems share many properties: They are daunting—there’s so much to do!
We don’t know were to begin
Not sure we know all of the tasks that must be done to produce a solution
Not sure we know how to do all of the parts— new knowledge may be required
Not sure it is within our capability—maybe an expert is needed
2012-05-14 Katherine Deibel, Fluency in Information Technology 43
![Page 44: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/44.jpg)
Problem Decomposition
“Divide and conquer” is a political strategy, military strategy and IT strategy
Top-level Plan for Algorithm Building
1. Describe (in any language) a series of steps that produce a solution
2. For each step, solve it or decompose further
3. For steps needing decomposition, repeat 2
4. Assemble solutions and test correctness
5. When solution fully assembled, evaluate
2012-05-14 Katherine Deibel, Fluency in Information Technology 44
![Page 45: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/45.jpg)
1. Give Steps to a Solution
Specify (in any language) a series of steps that produce a solution For a huge problem the steps may at first be
vague, but they can be (and must be) made more precise as the whole picture emerges
The goal is an algorithm(s), so List and describe the inputs
List and describe the outputs Be guided by figuring out how to transform
the inputs into the outputs
2012-05-14 Katherine Deibel, Fluency in Information Technology 45
![Page 46: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/46.jpg)
2 and 3. Solve or Decompose
For each step, solve it or decompose it further, i.e. apply same technique
Most “top level” steps can’t be brained out, and need further decomposition
“Top level” steps often seem huge, too
The technique allows one to concentrate on only one problem at a time
As before, focus on transforming inputs to intermediary outputs to final outputs
2012-05-14 Katherine Deibel, Fluency in Information Technology 46
![Page 47: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/47.jpg)
Katherine Deibel, Fluency in Information Technology 47
4. Assemble and Test
Putting solutions together can be tough because of different assumptions made while solving the parts
A common practice is to combine parts along the way and to test continuously
Because of the need to test, pick a good order to solve the problems
Mistakes and backtracking are inevitable
2012-05-14
![Page 48: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/48.jpg)
Example: Fingerspelling Lab The Design a Web App Lab showed
some of the basic ideas of writing an algorithm / program Breaking down parts of the problem
Testing along the way
Continual effort to just progress forward
2012-05-14 Katherine Deibel, Fluency in Information Technology 48
![Page 49: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/49.jpg)
Example: Chapter 22
Implements Smooth Motion page:http://preview.tinyurl.com/fit-smooth
Fairly big application 125 lines
2500 nonspace characters
6 functions Chapter details the process
of divide-and-conquer
2012-05-14 Katherine Deibel, Fluency in Information Technology 49
![Page 50: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/50.jpg)
Summary
Algorithms describe the precise steps to solve a problem Fundamental concept in computer science
Concerned with correctness, efficiency, and finiteness
Building algorithms is about abstracting and breaking down a problem We do this all the time
The challenge of programming is telling a computer how to do the algorithm
2012-05-14 Katherine Deibel, Fluency in Information Technology 50
![Page 51: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/51.jpg)
5. What does the following JavaScript algorithm do? Assume myArr.length > 0 and contains numbers.
var i, k;function mystery(myArr) { k = 0; for (i = 1; i < myArr.length; i++) { if (myArr[i] < myArr[k]) { k = i; } } return k;}
A. B. C. D.
25% 25%25%25%
A. Returns myArr[k]B. Sorts myArr in descending orderC. Sorts myArr in ascending orderD. Returns index of smallest element in myArr
2012-05-14 Katherine Deibel, Fluency in Information Technology 51
![Page 52: Lab 9 and Project 2B instructions are posted on the calendar page Start early Voting for Best Hoax Pages is up on the calendar page Due by Thursday,](https://reader035.fdocuments.in/reader035/viewer/2022062518/56649ec05503460f94bcc4fb/html5/thumbnails/52.jpg)
2012-05-14 Katherine Deibel, Fluency in Information Technology 52
5. What does the following JavaScript algorithm do? Assume myArr.length > 0 and contains numbers.
var i, k;function mystery(myArr) { k = 0; for (i = 0; i < myArr.length; i++) { if (myArr[i] < myArr[k]) { k = i; } } return k;}
A. Returns myArr[k]B. Sorts myArr in descending orderC. Sorts myArr in ascending orderD. Returns index of smallest element in myArr
The for loop goes through the length of myArr and returns just the index of the smallest value.