Upload
lini-ickpnn
View
212
Download
0
Embed Size (px)
DESCRIPTION
s
Citation preview
Analysis and Design of AlgorithmsAn algorithm is a method of solving problem (on a computer)Problem example:given a set of points on the planefind the closest pairAlgorithm:find distance between all pairs Can we do it faster?
Combinatorial ProblemsClosest pairO(n^2) algorithmTSPO(n!) algorithmtoo slowdifficult problem
Course OverviewGeneral algorithmic methodsdivide and conquer, greedy algorithms, dynamic programmingData structureshashing, priority queues, binary search trees, binomial heapsCombinatorial problemsMST, TSP, Vertex/Set Cover, Matrix Computational Complexity NP-completeness, reducibility, approximationCormen-Leiserson-Rivest Introduction to Algorithms
GradingHome work 1/3problems from Cormen ... two programming assignments4 Quizes 1/34520 Final 1/36520 Project 1/3
Home Work Problem setsweeklyhanded in/out Tuesdays (usually)Extra-credit problems!Due next Tuesday 1.4-1 p.17 / 1.2-2 p.131.4-2 p.17 / 1.2-2 p.13
SortingInput: sequence of numbers Output: a sorted sequence Insertion-Sortfor j = 2 to n docurrent=A[j]i = j - 1while i > 0 & A[i] > current doA[i + 1] = A[i]i = i - 1A[i + 1] = current
How it worksInsertion-Sortfor j = 2 to n docurrent = A[j]next currenti = j - 1go leftwhile i > 0 A[i] & A[i] > current dofind place for currentA[i + 1] = A[i]shift sorted righti = i - 1go leftA[i + 1] = currentput current in place
Running TimeDepends oninput size input quality (partially ordered)Kinds of analysisWorst case(standard)Average case(sometimes)Best case(never)
Asymptotic AnalysisIgnore machine dependent constantsLook at growth of T(n) while n O - notationO(n^3)>O(n^2)
Insertion Sort AnalysisWorst Case O(n^2)Average Case O(n^2)Can we do better?New paradigms