Analysis_UMD_CIS_350_Winter19.ppt - Analysis of Algorithms Input © 2010 Goodrich Tamassia Algorithm Analysis of Algorithms Output 1 Running Time Most

# Analysis_UMD_CIS_350_Winter19.ppt - Analysis of Algorithms...

• Notes
• 31

This preview shows page 1 - 9 out of 31 pages.

Analysis of Algorithms Algorithm Input Output © 2010 Goodrich, Tamassia 1 Analysis of Algorithms

Subscribe to view the full document.

Analysis of Algorithms 2 Running Time Most algorithms transform input objects into output objects. The running time of an algorithm typically grows with the input size. Average case time is often difficult to determine. We focus on the worst case running time. Easier to analyze Crucial to applications such as games, finance and robotics 0 20 40 60 80 100 120 Running Time 1000 2000 3000 4000 Input Size best case average case worst case © 2010 Goodrich, Tamassia
Analysis of Algorithms 3 Experimental Studies Write a program implementing the algorithm Run the program with inputs of varying size and composition Use a method like clock() to get an accurate measure of the actual running time Plot the results 0 1000 2000 3000 4000 5000 6000 7000 8000 9000 0 50 100 Input Size Time (ms) © 2010 Goodrich, Tamassia

Subscribe to view the full document.

Analysis of Algorithms 4 Limitations of Experiments It is necessary to implement the algorithm, which may be difficult Results may not be indicative of the running time on other inputs not included in the experiment. In order to compare two algorithms, the same hardware and software environments must be used © 2010 Goodrich, Tamassia
Analysis of Algorithms 5 Theoretical Analysis Uses a high-level description of the algorithm instead of an implementation Characterizes running time as a function of the input size, n . Takes into account all possible inputs Allows us to evaluate the speed of an algorithm independent of the hardware/software environment © 2010 Goodrich, Tamassia

Subscribe to view the full document.

Analysis of Algorithms 6 Pseudocode High-level description of an algorithm More structured than English prose Less detailed than a program Preferred notation for describing algorithms Hides program design issues Algorithm arrayMax ( A , n ) Input array A of n integers Output maximum element of A currentMax A [0] for i 1 to n 1 do if A [ i ] currentMax then currentMax A [ i ] return currentMax Example: find max element of an array © 2010 Goodrich, Tamassia
Analysis of Algorithms 7 Pseudocode Details Control flow if then [ else …] while do repeat until for do Indentation replaces braces Method declaration Algorithm method ( arg [, arg …]) Input Output Method call var.method ( arg [, arg …]) Return value return expression Expressions Assignment (like in C++) Equality testing (like  in C++) n 2 Superscripts and other mathematical formatting allowed © 2010 Goodrich, Tamassia

Subscribe to view the full document.

Analysis of Algorithms 8 The Random Access Machine (RAM) Model A CPU An potentially unbounded bank of memory cells, each of which can hold an arbitrary number or character 0 1 2 Memory cells are numbered and accessing any cell in memory takes unit time.
• Winter '19
• JAMES
• Big O notation, Analysis of algorithms

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes