Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science CS 330: Algorithms Gene Itkis. Computer Science CS-330: Algorithms, Fall 2008Gene Itkis2 Algorithms: What?  Systematic procedure that.

Similar presentations


Presentation on theme: "Computer Science CS 330: Algorithms Gene Itkis. Computer Science CS-330: Algorithms, Fall 2008Gene Itkis2 Algorithms: What?  Systematic procedure that."— Presentation transcript:

1 Computer Science CS 330: Algorithms Gene Itkis

2 Computer Science CS-330: Algorithms, Fall 2008Gene Itkis2 Algorithms: What?  Systematic procedure that produces —in a finite number of steps— the solution of a problem Encyclopædia Britannica  Euclid (300 BC): gcd algorithm  Other examples (that you already know/use) :  Division, multiplication  Sorting/searching ……

3 Computer Science CS-330: Algorithms, Fall 2008Gene Itkis3 Algorithms: Why?  Performance  Structure/Modularity  Maintanability + Extensibility + Robustness  Simplicity  Correctness  Reliability  Scalability  Predictability  Job security ……

4 Computer Science CS-330: Algorithms, Fall 2008Gene Itkis4 Algorithms: Why? (take 2)  Web/Internet:  Searching  sorting, selection, search trees, matrix computation, …  Networking & Routing  Shortest path, MST, connectivity, nearest neighbors, flow, …  Communication  Data compression, error-detecting/correcting codes  Security/Cryptography  Large numbers arithmetic, primes generation, RSA, …  IDS/Firewalls: string matching, finite automata,… ……

5 Computer Science CS-330: Algorithms, Fall 2008Gene Itkis5 Algorithms: Why? (take 2)  Image, Video, Audio  JPEG, MPEG, fractal coding,…  Graphics  Geometric algorithms, ray tracing, …  Biology  String alignment, DNA sequencing, …  Scientific simulations  Eigenvalues, triangulation, …  Other/everywhere  Optimization, linear programming, …  Scheduling ……

6 Computer Science CS-330: Algorithms, Fall 2008Gene Itkis6 Algorithms: How?  This course, of course  From bureaucrats to machines  Precision  Structure:  Modularity  Layers of abstraction  Analysis: proofs  Learn from Examples

7 Computer Science CS-330: Algorithms, Fall 2008Gene Itkis7 Problem statement  Input/output  Sorting  Input: Array[1…n] of n elements in arbitrary order  Output: Array[1…n] of the same n elements but in the non-decreasing order  Access methods  Dictionary  New() : creates a new empty dictionary  Insert(x, key) : inserts record x under the key  Find(key) : returns element x which was previously Insert ed under the key (nil, if none) ……

8 Computer Science CS-330: Algorithms, Fall 2008Gene Itkis8 Sorting (review from cs112+)  Strategies  Greedy  Divide & Concur  Reduction  From a “bigger”/harder problem to a “smaller”/simpler one  Analysis  Recurrences  Do not forget details of implementation  Link-lists or Arrays?

9 Computer Science CS-330: Algorithms, Fall 2008Gene Itkis9 Selection Sort  Idea  Algorithm:  for i= 1 to n do // find min element in A[i...n] // and put it in the i'th position (i.e. at A[i])  min_index <-- i  //locate min for j= i+1 to n do  if A[j] < A[min_index] then min_index <-- j  //put the min where it belongs swap( A[i], A[min_index] ) 6 4 527 1 3

10 Computer Science CS-330: Algorithms, Fall 2008Gene Itkis10 Selection Sort for i= 1 to n do min_index <-- i for j= i+1 to n do if A[j] < A[min_index] then min_index <-- j swap( A[i], A[min_index] ) 6452713i min_index j


Download ppt "Computer Science CS 330: Algorithms Gene Itkis. Computer Science CS-330: Algorithms, Fall 2008Gene Itkis2 Algorithms: What?  Systematic procedure that."

Similar presentations


Ads by Google