Intro to Computer Algorithms Lecture 1 Phillip G. Bradford Computer Science University of Alabama
Announcements ACM initial meeting of the year. Thursday, August 28th, 5:00pm in East Eng. 119 Industrial Colloquium Series Tuesday, September 2nd, 5:00pm in EE 119 Herschel Chandler presents: “Being an Independent Computer Consultant”
General Lecture Format Some power-point slides Some white-board writing Details are very important Lots of Interaction a good thing
Lecture Outline Syllabus Learning Grading Your Expectations My Expectations Material: High Level Overview Motivation Foundations, History and Perspective Applications of Algorithms & the Future
Lecture Outline The book by A. Levitin Design paradigms approach Nice way to think about design & analysis Classifications of challenges on how they are solved Commonalities are the solutions Let’s get started Chapter 1.1 to 1.3
My Expectations Exercise gives strength This is an exercise course Excellent Students give excellent results Given some work What are your expectations? Survey
Motivation How hard is it to solve Computer Challenges? Deep Question…heavy ramifications Optimization Applications Networks Financial Models, business issues, etc. Real-Time Applications Airplanes, trains, missiles Sensors, medical applications, etc.
Motivation Foundational questions Sorting & searching Exhaustive Search Apparent hardness of old and new challenges Cuts across engineering and other math & science disciplines
Algorithms What is an algorithm? Unambiguous list of instructions that solve a challenge Gives the right answer on legitimate input What about algorithms that use randomness? Designed with randomness in mind Really, pseudo-random numbers
Algorithms: what to do… Page 10, Figure 1.2 Understand the challenge! Design an algorithm Easy sub cases first, perhaps Prove correctness Analyze the algorithm Check & improve design if analysis warrants Iterate, iterate, …
Euclid’s Algorithm The challenge Greatest-common divisors GCD(12,6) = 6 GCD(17,16) = 1 GCD(20,15) = 5 Euclid’s method GCD(m,0) = m GCD(m,n) = GCD(n, m mod n)
Euclid’s Algorithm, cont. Book example: GCD(60,24) = GCD(24,12) = GCD(12,0) = 12 Euclid(m,n) While(n != 0) { r m mod n; m n; n r; } Return m;
Euclid’s Algorithm Correctness? Halts? Prime-Factor approach How? Which is better?? Relative costs?
Sieve of Eratosthenes Challenge: given an integer n, find all primes <= n. Example: n = 18, then output: 2,3,5,7,11,13,17 Elimination of prime candidates by potential factors Claim: the largest potential factor: floor(sqroot(n))
Types of Problems Sorting, Searching Stable Sorts String Processing Graph problems Combinatorial problems TSP Geometric Problems Numerical Problems
Homework set Due Tuesday Page 8, #5, #6 Page 17, #1 Page 18, #3, #8