Algorithms and OOD (CSC 207 2013F) : Outlines

Outline 19: Analyzing Algorithms


Held: Tuesday, 1 October 2013

Back to Outline 18 - Building Your First App (2). On to Outline 20 - Linear and Binary Search.

Summary

We consider ways, formal and informal, to describe the running time of algorithms.

Related Pages

Overview

Administrivia

A Motivating Problem: Exponentiation

Here's a simple iterative solution using a for loop

double result = 1.0;
for (int i = 0; i < y; i++)
    result *= x;

Here's a divide and conquer solution.

 To compute x^y
 If y is 0
   return 1
 Else if y is odd
   return x*x^(y-1)
 Else if y is even
   return square(x^(y/2))

Comparing Algorithms

Potential Problems

Is there an exact number we can provide for the running time of an algorithm? Surprisingly, no.

Asymptotic Analysis

Big-O Formalized

Implications of Big-O

You can formally prove all of the following (and probably will, in some course)

Doing Informal Asymptotic Analysis

Recurrence Relations

Let's try to figure out the running time of a few recursive algorithms given descriptions of the relationships of running times.

I find it easiest to "work out" some example inputs and then to look for patterns.

Experimental Analysis

Copyright (c) 2013 Samuel A. Rebelsky.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.