1 / 9

CS 330: Algorithms

CS 330: Algorithms. Gene Itkis. 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

cree
Download Presentation

CS 330: Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 330: Algorithms Gene Itkis

  2. Algorithms: What? • Systematic procedure that produces—in a finite number of steps—the solution of a problemEncyclopædia Britannica • Euclid (300 BC): gcd algorithm • Other examples (that you already know/use): • Division, multiplication • Sorting/searching • … Gene Itkis

  3. Algorithms: Why? • Performance • Structure/Modularity • Maintanability + Extensibility + Robustness • Simplicity • Correctness • Reliability • Scalability • Predictability • Job security • … Gene Itkis

  4. 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,… • … Gene Itkis

  5. 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 • … Gene Itkis

  6. Algorithms: How? • This course, of course  • From bureaucrats to machines • Precision • Structure: • Modularity • Layers of abstraction • Analysis: proofs • Learn from Examples Gene Itkis

  7. 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 Inserted under the key (nil, if none) • … Gene Itkis

  8. 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? Gene Itkis

  9. 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 minfor j= i+1 to n do • if A[j] < A[min_index] then min_index <-- j • //put the min where it belongsswap( A[i], A[min_index] ) 2 5 3 1 7 6 4 Gene Itkis

More Related