CS333 Algorithms - PowerPoint PPT Presentation

Loading...

PPT – CS333 Algorithms PowerPoint presentation | free to download - id: 70d112-ZGQwZ



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

CS333 Algorithms

Description:

CS333 Algorithms http://www.cs.binghamton.edu/~kang/teaching/cs333/ – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 29
Provided by: Lij98
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: CS333 Algorithms


1
CS333 Algorithms
  • http//www.cs.binghamton.edu/kang/teaching/cs333/

2
Course Objectives
  • Critical thinking for problem solving
  • Develop correct and efficient algorithms
  • Analysis of time and space complexity
  • Learn key algorithms and learn how to analyze and
    compare them
  • Learn how to design algorithms using well known
    methods such as divide and conquer, greedy
    methods, and dynamic programming
  • Theory of NP-completeness
  • Enjoy the beauty of algorithms!

3
Chapter 1
  • Definition of algorithms
  • Sample problems and algorithms
  • Review of basic math needed for this course as
    necessary
  • Analysis
  • Time complexity
  • Notion of Order big O, small o, ?, T

4
Basic Concepts
  • Algorithm A step-by-step procedure for solving a
    problem.
  • Exemplar problems
  • - Sort a list S of n numbers in
    non-decreasing order
  • - Determine whether a number x is in the
    list S of n numbers
  • - Matrix multiplication

5
Importance of Algorithm Efficiency
  • Time
  • Storage
  • Example
  • - Sequential search vs. binary search
  • Basic operation comparison
  • Number of comparisons grows at
    different rates
  • - nth Fibonacci sequence
  • Recursive versus iterative solutions

6
Example search strategy
  • Sequential search vs. binary search
  • Problem determine whether x is in the
    sorted array S of n keys
  • Inputs key x, positive integer n, sorted
    (non-decreasing order) array of keys S indexed
    from 1 to n
  • Output location of x in S (0 if x is not
    in S)

7
Example search strategy
  • Sequential search
  • Basic operation comparison
  • Void Seqsearch(int n, const keytype S, keytype
    x, index location)
  • location1
  • while(locationltn Slocation ! x)
  • location
  • if(location gt n) location 0

8
Example search strategy
  • Binary search
  • Basic operation comparison
  • Void Binsearch(int n, const keytype S, keytype
    x, index location)
  • index low, high, mid
  • low 1 high n location0
  • while(lowlthigh location 0)
  • mid floor((lowhigh)/2)
  • if(xSmid) location mid
  • else if (xlt Smid) high mid -1
  • else(low mid 1)

9
Example number of comparisons
  • Sequential search
  • n 32 128 1024
    1,048,576
  • Binary search
  • lg(n) 1 6 8 11 21
  • Eg
  • S1,, S16,, S24, S28, S30, S31,
    S32
  • (1st) (2nd) (3rd)
    (4th) (5th) (6th)

10
Analysis of Time Complexity
  • Input size
  • Basic operation
  • Time complexity for the size of input, n
  • - T(n) Every-case time complexity
  • - W(n) Worst-case time complexity
  • - A(n) Average-case time complexity
  • - B(n) Best-case time complexity
  • T(n) example
  • - Add array members Matrix multiplication
    Exchange sort
  • T(n) n-1 nnn
    n(n-1)/2

11
Math preparation
  • Induction
  • Logarithm
  • Sets
  • Permutation and combination
  • Limits
  • Series
  • Asymptotic growth functions and recurrence
  • Probability theory

12
Programming preparation
  • Data structure
  • C
  • C

13
Presenting Commonly used algorithms
  • Search (sequential, binary)
  • Sort (mergesort, heapsort, quicksort, etc.)
  • Traversal algorithms (breadth, depth, etc.)
  • Shortest path (Floyd, Dijkstra)
  • Spanning tree (Prim, Kruskal)
  • Knapsack
  • Traveling salesman
  • Bin packing

14
Well known problem
  • Problem Given a map of North America, find the
    best route from New York to Orlando?
  • Many efficient algorithms
  • Choose appropriate one (e.g., Floyds algorithm
    for shortest paths using dynamic programming)

15
Another well known problem
  • Problem You are supposed to deliver newspapers
    to n houses in your town. How can you find the
    shortest tour from your home to everybody on your
    list and return to your home?
  • One solution to traveling salesperson problem
    dynamic programming

16
Another well known problem (continued)
  • No efficient algorithm to general problem
  • Many heuristic and approximation algorithms
    (e.g., greedy heuristic)
  • Choose appropriate one

17
Another well known problem (continued)
  • Computational Geometry
  • Find a convex hull
  • Delaunay triangulation
  • Voronoi Diagram

18
Design Methods or Strategies
  • Divide and conquer
  • Greedy
  • Dynamic programming
  • Backtrack
  • Branch and bound

19
Not addressed (Advanced algorithms)
  • Genetic algorithms
  • Neural net algorithms
  • Algebraic methods

20
Theory of NP completeness
  • Many common problems are NP-complete
  • traveling salesperson, knapsack,...
  • NP non-deterministic polynomial
  • Fast algorithms for solving NP-complete problems
    probably dont exist
  • Approximation algorithms are used (e.g., minimum
    spanning tree derived by Prims algorithm using
    triangle inequality)

21
Are algorithms useful?
  • Hardware
  • Software
  • Economics
  • Biomedicine
  • Computational geometry (graphics)
  • Decision making
  • Scheduling ..

Great algorithms are the poetry of computation
22
Hardware Design
  • VLSI design
  • Multiplication
  • Search
  • Sort networks

Selection sort for A1, , An-1
3 7 8 6 2
2 3 6 7 8
23
Software
  • Text processing
  • String matching, spell checking, and pretty
    print,
  • Networks
  • Minimum spanning trees, routing algorithms,
  • Databases
  • Compilers

24
Text processing pretty print
  • I want
  • this page
  • to look good
  • I want this page
  • to look good
  • Method Dynamic programming

25
Engineering
  • Optimization problem (e.g., finite element,
    energy minimization, dynamic simulation).
  • Best feature selection for object representation
    and biometrics recognition (e.g., Genetic
    Algorithm)
  • Mathematics geometric simulation and
    approximation (e.g., algorithm approximation)
  • Graphics visualization (e.g., area filling and
    scan conversion, 3D key framing).
  • Signal analysis FFT, Huffman coding

26
Economics
  • Transportation problems
  • Shortest paths, traveling salesman, knapsack, bin
    packing
  • Scheduling problems
  • Location problems (e.g., Voronoi Diagram)
  • Manufacturing decisions

27
Social decisions
  • Matching problem
  • Assigning residents to hospitals
  • Matching residents to medical program

28
Critical thinking for problem solving
  • Consider different approaches to solving a
    problem such as dynamic programming and greedy
    approaches
  • Analyze the merits of each
  • Consider different implementations for a chosen
    approach
  • Analyzing the merit of the different
    implementation
About PowerShow.com