1 / 23

CS 312: Algorithm Analysis

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. CS 312: Algorithm Analysis. Lecture #1: Algorithms and Efficiency. Slides by: Eric Ringger, with contributions from Mike Jones, Eric Mercer, Sean Warnick. Introduction. Prayer

dolf
Download Presentation

CS 312: Algorithm Analysis

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. This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. CS 312: Algorithm Analysis Lecture #1: Algorithms and Efficiency Slides by: Eric Ringger, with contributions from Mike Jones, Eric Mercer, Sean Warnick

  2. Introduction • Prayer • Spiritual/interesting thought

  3. Thought “Education is not the filling of a bucket but the lighting of a fire.” W. B. Yeats

  4. Objectives for Today • Introduce course objectives • Quickly cover course info. • Define Problems, Solutions, and Algorithms • Introduce 3 Questions • Motivate the need for Analysis

  5. Course Objectives • Develop your general problem solving skills! • Learn to perform theoretical analysis of algorithms • Learn to perform empirical analysis of algorithms • Compare theoretical and empirical analysis • Become familiar with several families of algorithms suitable for solving many kinds of problems • Use Visual Studio and C#

  6. Course Info. • Office Hours: TBD & By appointment • Web page: https://facwiki.cs.byu.edu/cs312sum2012 • Syllabus – read today! • Regularly updated schedule • Due dates • Reading assignments • Homework assignments • Project guidelines • Lecture notes • Email: paul_felt AT byu DOT edu

  7. More Course Info. • Google Group: “BYU CS 312 Summer” • Announcements • Forum for discussion • Subscribe and participate! • Gradebook: http://gradebook.byu.edu

  8. Work Load • 6 hours/week in class • 12 hours/week out of class • Weekly projects • Daily Reading and Homework

  9. Course Policies • Grades • Early • Late • Other See syllabus for details

  10. Another Thought “Computer Science is no more about computers than Astronomy is about telescopes.” -- Michael R. Fellows and Ian Parberry * * often misattributed to Edsger Dijkstra!

  11. Definitions • What is a problem? • What is a solution?

  12. Output Set Solution: Algorithm Domain Range Problems and Their Solutions Problem: Input Set Problem Instances ComputingDevice

  13. Properties of an Algorithm algorithm • “A finite sequence of well-defined steps for solving a problem.” (like a recipe) • Also Interested in Efficiency (as a function of inputs)

  14. A Little History Abu JafarMuḥammadibnMūsā • ca. 780 – ca. 850 • “al-Khwārizmī” • “the (man) of Khwarizm”, his place of origin • Khiva in present-day Uzbekistan and Turkmenistan • Persian astronomer and mathematician • Worked in Baghdad • Authored many texts on arithmetic and algebra • Methods for • Adding • Multiplying • Dividing • Extracting square roots • Calculating digits of  • Properties: • Precise • Unambiguous • Mechanical • Efficient • Correct Leonardo of Pisa, “Fibonacci” • ca. 1170 – ca. 1250 • Coined “algorithms” in his honor. • Also imported Hindu-Arabic numeral system

  15. Fibonacci 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, … Problem: compute the nth Fibonacci number, described here as mathematical recurrence relation

  16. Solution: Algorithm Function (first draft) for computing the n-th Fibonacci number Fn(assume ) function fib1(n) if n=0: return 0 if n=1: return 1 return fib1(n-1) + fib1(n-2)

  17. Three Questions • Is it correct? • How much time does it take, as a function of n? • Can we do better?

  18. Is it Correct? function fib1(n) if n=0: return 0 if n=1: return 1 return fib1(n-1) + fib1(n-2)

  19. How much time does it take as a function of n? • for • For , two recursive invocations of fib1() • Requiring time • And time • Thus, • for • Notice that • Not good! • is exponential in

  20. Can we do better? • Key idea: Store the intermediate results function fib2(n) if n=0: return 0 create an array f[0..n] f[0] = 0, f[1] = 1 for i = 2 .. n: f[i] = f[i-1] + f[i-2] return f[n]

  21. Our Problem Solving Strategy • For a given problem, • Pick a computational platform (with associated elementary operations) • Write an algorithm to solve the problem • Ask the three questions: • Make sure that it is correct • Analyze the efficiency of the algorithm • Look for opportunities for improvement

  22. “A person well trained in computer science knows how to deal with algorithms: how to construct them, manipulate them, understand them, analyze them. This knowledge is preparation for much more than writing good computer programs; it is a general-purpose mental tool that will be a definite aid to the understanding of other subjects, whether they be chemistry, linguistics, or music, etc. The reason for this may be understood in the following way: It has often been said that a person does not really understand something until after teaching it to someone else. Actually, a person does not really understand something until after teaching it to a computer, i.e. expressing it as an algorithm…An attempt to formalize things as algorithms leads to a much deeper understanding than if we simply try to comprehend things in the traditional way.” Donald Knuth from Selected Papers on Computer Science,1996 Why Rigorous Analysis?

  23. Assignment • Submit your schedule constraints on whenisgood calendar • Join Google Group • byu-cs-312-summer@googlegroups.com • Visual Studio • Install Visual Studio (follow directions in syllabus) or use an open lab machine • Try out C# using tutorials (see links in syllabus)

More Related