cs126 asymptotic analysis

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/32

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

33 Terms

1
New cards

Why is the worst-case running time measured?

  • Easier to analyse (as average case would require knowing the input distribution)

  • Crucial to applications like games, finance, and robotics

2
New cards

Describe how the ‘Experimental’ approach is used to evaluate the running time of an algorithm.

  • Write a program implementing the algorithm

  • Run the program with inputs of varying size and composition

  • Record the time needed for each of these inputs

  • Plot the results

3
New cards

What are the limitations of the Experimental approach?

  • It is necessary to implement the algorithm, which may be difficult

  • In order to compare two algorithms, the same hardware and software environments must be used

4
New cards

Describe how the ‘Theoretical’ approach is used to evaluate the running time of an algorithm.

  • Uses a high-level description of the algorithm instead of an implementation

  • Characterizes running time as a function of the input size n, denoted T(n)

  • Independent of the hardware/software environment

  • Can be performed given pseudocode

5
New cards

What makes a good analysis approach?

  • Independent of hardware / software environment

  • Does not require actually implementing the algorithm

  • Takes into account all possible inputs

6
New cards

What is pseudocode?

  • High-level description of an algorithm

  • Less detailed than a program

  • Hardware / software independant

7
New cards

What does RAM consist of?

A potentially unbounded bank of memory cells, each of which can hold an arbitrary number or character.

8
New cards

Define a memory cell.

  • A numbered location in memory

  • Accessing any cell takes unit time

9
New cards

Define asymptotic analysis.

  • Compares relative growth rates of two (or more) functions/algorithms

  • Independent of constant multipliers or low-order effects

10
New cards

How do you perform asymptotic analysis?

  • Find the worst case number of primitive operations executed as a function of the input size

  • Express this function with Big-O notation

11
New cards

What is Big ‘O’ Notation?

  • O(g(n))

  • {f(n) : (constants) c > 0, n0 ≥ 0 : f(n) ≤ cg(n) ∀n ≥ n0}

  • f(n) is bounded from above by g(n)

  • is a set of functions

12
New cards

What is Big ‘Omega’ Notation?

  • Ω(g(n))

  • iff c, n0 > 0 : ∀n ≥ n0, f(n) ≥ cg(n) ≥ 0 

  • f(n) is bounded from below by g(n)

13
New cards

What is Big ‘Theta’ Notation?

  • ϴ(g(n))

  • iff c1,c2,n0 > 0 : 0 ≤ c1g(n) ≤ f(n) ≤ c2g(n), ∀n ≥ n0

  • f(n) and g(n) have the same asymptotic growth rate

14
New cards

What is little ‘o’ / ‘omega’ notation? {EDIT}

little is strict

15
New cards

What is the rule of sum of functions?

O(f + g) = max(O(f), O(g))

16
New cards

What is the rule of product of functions?

O(f x g) = O(f) x O(g)

17
New cards

What is the growth rate of f(n) and g(n) if limn→∞ (f(n) / g(n)) = 0

f(n) = O(g(n))

18
New cards

What is the growth rate of f(n) and g(n) if limn→∞(f(n) / g(n)) > 0

f(n) = ϴ(g(n))

19
New cards

What is the growth rate of f(n) and g(n) if limn→∞(f(n) / g(n)) = ∞

f(n) = Ω(g(n))

20
New cards

What is the growth rate of f(n) and g(n) if limn→∞ (f(n) / g(n)) oscillates.

There is no relation.

21
New cards

a(b+c)

abac

22
New cards

abc

(ab)c

23
New cards

ab/ac

a(b-c)

24
New cards

nlog n (a)

a

25
New cards

logb(xy)

logbx +  logby

26
New cards

logb(x/y)

logbx - logby

27
New cards

logb(xa)

alogbx

28
New cards

an - bn

(a - b)(an-1 + an-2 b + an-3 b2 + … + bn-1)

29
New cards

2n - 1

1 + 2 + 4 + 8 + … + 2n-1

30
New cards

Define floor.

largest integer ≤ n

31
New cards

Define ceiling.

smallest integer ≥ n

32
New cards

What is the hierarchy of time costs (ordered by growth rate)?

c → logn → n → nlogn → n2 → n3 → 2n

33
New cards

What is the assumed default base of a log?

2