Analysis of Algorithms

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

algorithm design strategies

- brute force - divide and conquer - decrease and conquer - transform and conquer - greedy approach - dynamic programming - backtracking and brand and bound - space and time tradeoffs

steps in mathematical analysis of recursive algorithms

- decide on input size - identify algorithm's basic operation - determine worst, average, and best cases for input size n - set up a recurrence relation and initial condition(s) for C(n) - solve the recurrence to obtain a closed form or estimate the order of magnitude of the solution

steps in mathematical analysis of nonrecursive algorithms

- decide on input size - identify algorithm's basic operation - determine worst, average, and best cases for input size n - set up summation for C(n) reflecting algorithm's loop structure - simplify summation using standard formulas

steps in design and analysis of algorithms

- understand the problem - choose between approximate and exact problem solving - decide on data structures - algorithm design technique - methods of specifying an algorithm - prove algorithm correctness - analyze the algorithm - code the algorithm

complete graph

a graph with the maximum number of edges

algorithm

a sequence of unambiguous instructions for solving a problem

convex

a set of points in the plane are called convex if for any two points p and q in the set, the entire line segment with endpoints at p and q belongs to the set.

brute force

a straightforward approach usually based on problem statement and definitions of the concepts

T(n) = g(n)

c>0

bubble sort

compare adjacent elements and swap if out of order, repeat n-1 times.

undirected graph

edges are unordered pairs (v0, v1) = (v1, v0)

average case

expected number of basic operations repetitions considered as a random variable under some assumption about the probability distribution of all possible inputs of size n

principles of an algorithm

finiteness, difiniteness, input, output, effectiveness

euclid's algorithm

gcd(m, n) = gcd(n, m % n)

Russian peasant multiplication

if n is even: n/2 * 2m if n is odd: (n-1)/2 * 2m + m

T(n) > g(n)

infinity

interpolation search

like binary search except use linear interpolation on l and r to get the comparison value: x = l + floor[((v-A[l])(r-l)) / A[r]-A[l])] l is left boundary, r is right boundary, v is search value loglogn + 1

worst case

maximum over inputs of size n -> O(n)

best case

minimum over inputs of size n -> O(1)

brute force weaknesses

rarely yields efficient algorithms, some brute force algorithms unacceptably slow, not as constructive/creative as some other design techniques.

selection sort

sort for the smallest in a list of size n and swap it with the first element in the list, reduce the list size by 1 and repeat until n-1 passes are made

t(n) = t(n-1) + c; t(1) = d

t(n) = (n-1)c + d

t(n-1) +cn; t(1) = d

t(n) = [n(n+1)/2 - 1] c + d

t(n) = t(n/2) + c; t(1) = d

t(n) = c lg n + d

t(n) = 2t(n/2) + cn; t(1) = d

t(n) = cn lg n + dn

convex hull

the smallest convex set containing the set S

why study algorithms

theoretical importance, practical importance

brute force strengths

wide applicability - simplicity, yields reasonable algorithms for some important problems, yields standard algorithms for simple computational tasks

T(n) < g(n)

0

decrease and conquer

1) reduce problem instance to smaller instance of the same problem and extend solution 2) solve smaller instance 3) extend solution of smaller instance to obtain solution to original problem


संबंधित स्टडी सेट्स

Wheels in Motion Defensive Driving Exam and Quizzes

View Set

Chapter 55 Sensory deficit child

View Set

Prothero Cumulative Quiz Study Guide

View Set

Khan Academy Intro to JavaScript: Clarifying with Comments

View Set