O(n logba ) (p q)(x) p(x) q(x) O(n 2 ) 2n + 1. (p q)(x) O(n n)

Σχετικά έγγραφα
Αλγόριθμοι και πολυπλοκότητα NP-Completeness (2)

ΑΛΓΟΡΙΘΜΟΙ Άνοιξη I. ΜΗΛΗΣ

Fractional Colorings and Zykov Products of graphs

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής

EE512: Error Control Coding

Αλγόριθμοι Επανάληψη για πρόοδο

Nowhere-zero flows Let be a digraph, Abelian group. A Γ-circulation in is a mapping : such that, where, and : tail in X, head in

ΑΛΓΟΡΙΘΜΟΙ Άνοιξη I. ΜΗΛΗΣ

ΑΛΓΟΡΙΘΜΟΙ Άνοιξη I. ΜΗΛΗΣ

Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

2. THEORY OF EQUATIONS. PREVIOUS EAMCET Bits.

Minimum Spanning Tree: Prim's Algorithm

Πανεπιστήμιο Δυτικής Μακεδονίας. Τμήμα Μηχανικών Πληροφορικής & Τηλεπικοινωνιών. Τεχνητή Νοημοσύνη. Ενότητα 2: Αναζήτηση (Search)

Network Algorithms and Complexity Παραλληλοποίηση του αλγορίθμου του Prim. Αικατερίνη Κούκιου

HY380 Αλγόριθμοι και πολυπλοκότητα Hard Problems

Inverse trigonometric functions & General Solution of Trigonometric Equations

ANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =?

Matrices and Determinants

Αλγόριθμοι και πολυπλοκότητα Minimum Spanning Trees

Graph Algorithms. Παρουσίαση στα πλαίσια του μαθήματος «Παράλληλοι Αλγόριθμοι» Καούρη Γεωργία Μήτσου Βασιλική

Homework 3 Solutions

Σχέσεις, Ιδιότητες, Κλειστότητες

SCHOOL OF MATHEMATICAL SCIENCES G11LMA Linear Mathematics Examination Solutions

ΑΛΓΟΡΙΘΜΟΙ Άνοιξη I. ΜΗΛΗΣ

ΕΙΣΑΓΩΓΗ ΣΤΗΝ ΑΝΑΛΥΣΗ ΑΛΓΟΡΙΘΜΩΝ

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω

2 Composition. Invertible Mappings

Answers - Worksheet A ALGEBRA PMT. 1 a = 7 b = 11 c = 1 3. e = 0.1 f = 0.3 g = 2 h = 10 i = 3 j = d = k = 3 1. = 1 or 0.5 l =

Other Test Constructions: Likelihood Ratio & Bayes Tests

Second Order RLC Filters

Partition of weighted sets (problems with numbers)

ST5224: Advanced Statistical Theory II

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

Αλγόριθµοι και Πολυπλοκότητα

Matrices and vectors. Matrix and vector. a 11 a 12 a 1n a 21 a 22 a 2n A = b 1 b 2. b m. R m n, b = = ( a ij. a m1 a m2 a mn. def

Section 8.3 Trigonometric Equations

New bounds for spherical two-distance sets and equiangular lines

Quadratic Expressions

Finite Field Problems: Solutions

Αλγόριθμοι Ταξινόμησης Μέρος 3

The ε-pseudospectrum of a Matrix

Αλγόριθμοι Eλάχιστα μονοπάτια

Αλγόριθμοι και πολυπλοκότητα Depth-First Search

Partial Differential Equations in Biology The boundary element method. March 26, 2013

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1

Αλγόριθµοι και Πολυπλοκότητα

Αλγόριθμοι και πολυπλοκότητα Directed Graphs

Ορθότητα Χωρική αποδοτικότητα. Βελτιστότητα. Θεωρητική ανάλυση Εμπειρική ανάλυση. Αλγόριθμοι - Τμήμα Πληροφορικής ΑΠΘ -4ο εξάμηνο 1

Συστήματα Διαχείρισης Βάσεων Δεδομένων

Optimal Impartial Selection

k A = [k, k]( )[a 1, a 2 ] = [ka 1,ka 2 ] 4For the division of two intervals of confidence in R +

ΤΜΗΜΑ ΗΛΕΚΤΡΟΛΟΓΩΝ ΜΗΧΑΝΙΚΩΝ ΚΑΙ ΜΗΧΑΝΙΚΩΝ ΥΠΟΛΟΓΙΣΤΩΝ

Surface Mount Multilayer Chip Capacitors for Commodity Solutions

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

Επίλυση Προβληµάτων µε Greedy Αλγόριθµους

Αλγόριθµοι και Πολυπλοκότητα

Bounding Nonsplitting Enumeration Degrees

Chapter 6: Systems of Linear Differential. be continuous functions on the interval

If we restrict the domain of y = sin x to [ π, π ], the restrict function. y = sin x, π 2 x π 2

Approximation of distance between locations on earth given by latitude and longitude

Jesse Maassen and Mark Lundstrom Purdue University November 25, 2013

Numerical Analysis FMN011

Distances in Sierpiński Triangle Graphs

If we restrict the domain of y = sin x to [ π 2, π 2

Areas and Lengths in Polar Coordinates

derivation of the Laplacian from rectangular to spherical coordinates

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

Practice Exam 2. Conceptual Questions. 1. State a Basic identity and then verify it. (a) Identity: Solution: One identity is csc(θ) = 1

Γράφηµα (Graph) Εργαστήριο 10. Εισαγωγή

Probability and Random Processes (Part II)

Review Test 3. MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

TMA4115 Matematikk 3

SCITECH Volume 13, Issue 2 RESEARCH ORGANISATION Published online: March 29, 2018

Erkki Mäkinen ja Timo Poranen Algoritmit

CHAPTER 101 FOURIER SERIES FOR PERIODIC FUNCTIONS OF PERIOD

Section 7.6 Double and Half Angle Formulas

BMI/CS 776 Lecture #14: Multiple Alignment - MUSCLE. Colin Dewey

The challenges of non-stable predicates

C.S. 430 Assignment 6, Sample Solutions

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

Σχεδιαση Αλγοριθμων -Τμημα Πληροφορικης ΑΠΘ - Κεφαλαιο 9ο

Reminders: linear functions

(C) 2010 Pearson Education, Inc. All rights reserved.

ΑΛΓΟΡΙΘΜΟΙ. Ενότητα 2: Ανάλυση Αλγορίθμων. Ιωάννης Μανωλόπουλος, Καθηγητής Αναστάσιος Γούναρης, Επίκουρος Καθηγητής Τμήμα Πληροφορικής ΑΠΘ

Mock Exam 7. 1 Hong Kong Educational Publishing Company. Section A 1. Reference: HKDSE Math M Q2 (a) (1 + kx) n 1M + 1A = (1) =

Example Sheet 3 Solutions

Section 9.2 Polar Equations and Graphs

4.6 Autoregressive Moving Average Model ARMA(1,1)

Αλγόριθμοι Γραφημάτων

Aquinas College. Edexcel Mathematical formulae and statistics tables DO NOT WRITE ON THIS BOOKLET

ΕΠΛ 231 οµές εδοµένων και Αλγόριθµοι Άννα Φιλίππου,

ES440/ES911: CFD. Chapter 5. Solution of Linear Equation Systems

Statistical Inference I Locally most powerful tests

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

The Simply Typed Lambda Calculus

An Inventory of Continuous Distributions

Transcript:

y = b (x) x = b y b (xy) = b (x) + b (y) b (x) = b (c) c (x) = c (x) c (b) b (x n ) = n b (x) x a x b = x (a+b) (x a ) b = x (ab) x ( 1 2 ) = x x (a b) = xa x b k = n(n+1) 2 2k 1 = n 2 k 2 = n(n+1)(2n+1) 6 ar k 1 = a(1 rn ) 1 r ar k 1 = a 1 r O, Θ, and Ω f(n) n g(n) O(V + E) 0( ) f(n) Ω(g(n)) < (0) f(n) O(g(n)) = c, 0 < c < f(n) Θ(g(n)) (v i, v j ) i < j pre/post [u[v v]u] is a Tree/Forward Edge [v[u u]v] is a Back Edge [v v][u u] is a Cross Edge T (n) = at ( n/b ) + O(n d ) for a > 0, b > 1, and d 0, O(n d ) T (n) = O(n d logn) O(n logba ) a log b n a log bn = n log ba ifd > log b a ifd = log b a ifd < lob b a O(n n) (p q)(x) p(x) q(x) O(n 2 ) p(x) q(x) 2n + 1 O(n n) p(x) q(x) 2n + 1 (p q)(x) O(n) (p q)(x) O(n n) < values > < coeff > w < coeff > 1/n < values > w 1 function FFT(A, w) Input: Coefficient representation of a polynomial A(x) of degree less than or equal to n 1, where n is a power of 2w, an nth root of unity Output: Value representation A(w_0),...,A(w_n 1) if w = 1: return A(1) express A(x) in the form A_e(x^2) + xa_o(x^2) call FFT(A_e, w^2) to evaluate A_e at even powers of w call FFT(A_o, w^2) to evaluate A_o at even powers of w for j = 0 to n 1: compute A(w_j) = A_e(w^2j) + w^j A_o(w^2j) return A(w_0),...,A(w_n 1) O(V + E) (pre(u) < pre(v) < post(v) < post(u)) def explore(g,v): #Where G = (V,E) of a Graph Input: G = (V,E) is a graph; v V Output: visited(u) is set to true for all nodes u reachable from v visited(v) = true previsit(v) for each edge(v,u) in E: if not visited(u): postvisit(v) def dfs(g): explore(u) for all v in V: if not visited(v): explore(v) O(n) O(n) O(V + E) Input: Graph G = (V, E), directed or undirected; vertex s V Output: For all vertices u reachable from s, dist(u) is set to the distance from s to u. def bfs(g,s): Q = [s] (Queue containing just s) while Q is not empty: u = eject(u) for all edges (u,v) in E: if dist(v) = infinity: inject(q,v) dist(v) = dist(u) + 1 O(V + E) V def dijkstra(g,l,s): H = makequeue(v) # using dist values as keys while H is not empty: u = deletemin(h) for all edges (u,v) in E: if dist(v) > dist(u)+l(u,v) dist(v) = dist(u)+l(u,v) prev(v) = u decreasekey(h,v)

O(V E) procedure shortest-paths(g, l, s) Input: Directed graph G = (V, E); edge lengths {l_e: e in E} with no negative cycles; vertex s in V Output: For all vertices u reachable from s, dist(u) is set to the distance from s to u. repeat V -1 times: for all e in E: update(e) O(n) V 1 V 1 O(E E) E V 2 Input: A connected undirected graph G = (V,E) with edge weights w Output: A minimum spanning tree defined by the edges X X = {} makeset(u) Sort the edges E by weight for all edges {u,v} in E, in increasing order of weight: if find(u)!= find(v): add edge {u,v} to X union(u,v) E = V 1 G = (V, E) X e O(E E) E V 2 procedure prim(g, w) Input: A connected undirected graph G = (V, E) with weights Output: A minimum spanning tree defined by the array prev for all u in V : cost(u) = infinity Pick any initial node u_0 cost(u_0) = 0 H = makequeue (V) (priority queue with cost-values as keys) while H is not empty: v = deletemin(h) for each {v, z} in E: if cost(z) > w(v, z): cost(z) = w(v, z) prev(z) = v decreasekey(h, z) Input: A set of elements B; sets S1,...,Sm Output: A selection of the S_i whose union is B. Cost: Number of sets picked. Repeat until all elements of B are covered: Pick the set Si with the largest number of uncovered elements. pi rank x, rank(x) < rank(π(x)) k 2 k n n 2k k logn def makeset(x): // O(1) pi(x) = x rank(x) = 0 def find(x): // O(E log V) while x!= pi(x): x=pi(x) return x def union(x,y): // O(E log V) if find(x) == find(y): return elif rank(find(x)) > rank(find(y)): else: pi(find(y)) = find(x) pi(find(x))=find(y) if rank(find(x)) == rank(find(y)): function find(x): rank(find(y)) = rank(find(y)) + 1 if x!= pi(x): pi(x) = find(pi(x)) return pi(x) union(x, y) find(x) Olog n O(logN) O(nlog n) func huffman(f): Input: An array f[1...n] of frequencies Output: An encoding tree with n leaves let H be a priority queue of integers, ordered by f for i=1 to n: insert(h,i) for k = n+1 to 2n-1: i=deletemin(h), j=deletemin(h) create a node numbered k with children i,j f[k] = f[i]+f[j] insert(h,k)

θ( subproblems time/subproblem) i x[i :] i O(n) x[: i] i O(n) x[i : j] i, j O(n 2 ) O(n) memo = {} fib(n): if n in memo: return memo[n] if n <= 2: f = 2 else: f = fib(n-1) + fib(n-2) memo[n] = f return f fib = [] fib(n): for k in range(1, n): if k <= 2: f = 2 else: f = fib[k-1] + fib[n-2] fib[k] = f return fib[n] θ(v E) S k (s, v) = k S k (s, v) = min (u,v)ine (S k 1 (s, u) + w(u, v) O(n 2 ) L = {} for j=1,2,...,n: L[j] = 1+max{L[i]:(i,j) in E} # The (i,j) represents all the edges that go from # a node to j. return max(l) S _ N O W Y S U N N _ Y for i = 0,1,2,...,m: E(i,0) = i for j = 1,2,...,n: E(0,j) = j for i = 1,2,...,m: for j = 1,2,...,n: return E(m,n) E(i,j) = min{e(i-1,j)+1,e(i,j-1)+1,e(i-1,j-1) O(nW ) +diff(i,j)} K(ω) = max items {K(ω ω item ) + value} K(ω, j) = max available items {K(ω ω j, j 1) + V j, k(ω, j 1)} O(n 3 ) C(i, j) = min{c(i, k) + c(k + 1, j) + m i 1 m k m j } O( V 3 ) for i=1 to n: for j=1 to n: dist(i,j,0) = infinity for all (i,j) in E: for k = 1 to n: dist(i,j,0) = l(i,j) for i = 1 to n: for j = 1 to n: dist(i,j,k) = min{dist(i,k,k-1)+ dist(k,j,k-1), dist(i,j,k-1)} O(n 2 2 n ) C({1},1)=0 for s = 2 to n: for all subsets S in {1,2,...,n} of size s and has l: C(S,1) = infinity for all j in S,j!= 1: C(S,j) = min{c(s-{j},i)+dij:i in S,i not in j} return min over j, C({1,...,n},j)+dj1 (x + 2y) x 0, y 600 n i=1 a ix i b n i=1 a ix i + s = b s 0 ax = b ax b and ax b let v be any vertex of the feasible region while there is a neighbor v of v with a better value: return v set v = v

O(E M) M E O( E) O(V (E) 2 ) s t s t t 2 n n! x 1 x 2 x 3 (x 1 x 2 x 3 ) (x 4 x 5 x 6 ) x 1...x 6 s t g g B A A B A B A B B A A p B A B A B B C A C

Start with some problem P0 Let S = {P_0}, the set of active subproblems Repeat while S is nonempty: choose a subproblem P S and remove it from S expand it into smaller subproblems P_1, P_2,..., P_k For each P_i: If test (P_i) succeeds: halt and announce this solution If test (P_i) fails: discard Pi Otherwise: add P_i to S Announce that there is no solution A B Start with some problem P0 Let S = {P0}, the set of active subproblems bestsofar = infinity Repeat while S is nonempty: choose a subproblem (partial solution) P in S and remove it from S expand it into smaller subproblems P_1, P_2,..., P_k For each P_i: If P_i is a complete solution: update bestsofar else if lowerbound(pi) < bestsofar: add Pi to S return bestsofar A(I) α A = max(i) OP T (I) OP T (I) α A = max(i) A(I) (logn) 80 θ(nd) def Classify(x): set i* = 1 for i - 2, 3,..., n: if x-x_i < x-x_i*, set i* = i return y_i* θ(n(d + lgk))