Divide and Conquer Dynamic Programming Greedy Algorithm

Size: px
Start display at page:

Download "Divide and Conquer Dynamic Programming Greedy Algorithm"

Transcription

1 C 563 (95.573) LGORTHM NLY ND DGN Coceptios of algorithms Divide ad Coquer Dyamic Programmig Dr. Nejib Zaguia C563-W4 lgorithmic Paradigms Divide-ad-coquer. Break up a problem ito two subproblems, solve each sub-problem idepedetly, ad combie solutio to sub-problems to form solutio to origial problem. Dyamic programmig. Break up a problem ito a series of overlappig sub-problems, ad build up solutios to larger ad larger sub-problems. Greedy. Build up a solutio icremetally, myopically optimizig some local criterio. 2 Dyamic Programmig History Bellma. Pioeered the systematic study of dyamic programmig i the 95s. tymology. Dyamic programmig = plaig over time. ecretary of Defese was hostile to mathematical research. Bellma sought a impressive ame to avoid cofrotatio. "it's impossible to use dyamic i a pejorative sese" "somethig ot eve a Cogressma could object to" Referece: Bellma, R.. ye of the Hurricae, utobiography. 3

2 Dyamic Programmig pplicatios reas. Bioiformatics. Cotrol theory. formatio theory. Operatios research. Computer sciece: theory, graphics,, systems,. ome famous dyamic programmig algorithms. Viterbi for hidde Markov models. Uix diff for comparig two files. mith-waterma for sequece aligmet. Bellma-Ford for shortest path routig i etworks. Cocke-Kasami-Youger for parsig cotext free grammars. 4 Dyamic Programmig Geeral idea: try to avoid computig the solutio of the same sub problems more tha oce, by storig the computed sub solutios. This techique is used for optimizatio problems. Computig is doe from bottom to top. There are usually 4 steps i ay dyamic programmig algorithm: Characterize the structure of the optimal solutio. Defie the optimal solutio recursively Compute the optimal solutio from bottom to top. Combie the solutios for smaller problems stocked i the array to costruct a optimal solutio of the origial problem Dr. Nejib Zaguia C563-W4 5 Dyamic Programmig Problem: Matrix-chai multiplicatio How to compute efficietly the product: M = M M 2 M M i : d i, d i+ M = (...(M * M 2 )* M 3 )... M ) M = (M * M 2 )*(M 3 * M 4 ) *... M )... M = (M * (M 2 *... (M - * M )...) To compute the product of 2 matrices (p,q) ad B(q,r) we eed p*q*r multiplicatios. x (2 x (3 x 4 )) Cost(3 x 4 ) = 5 x x Cost(2 x (3 x 4 )) = 2 x 5 x Cost( x (2 x (3 x 4 ))) = x 2 x Total Cost = 25 = x 2 x 3 x 4 x2 2x5 5x x ( x (2 x 3)) x 4 Coût(2 x 3 ) = 2 x 5 x Coût( x (2 x 3 )) = x 2 x Coût(( x (2 x 3)) x 4 ) = x x Total Cost = 22 Dr. Nejib Zaguia C563-W4 6 2

3 Dyamic Programmig How to fid the most efficiet way to isert the parathesis. direct approach by checkig all possibilities will ot work. M = (M M 2 M i ) (M i+ M i+2 M ) T(i) T() = 2-2 T() = / ( - ) T() (4 / 3/2 ) - T() = T(i) T(-i) i= T(-i) Dr. Nejib Zaguia C563-W4 7 Dyamic Programmig Dyamic programmig approach ) tructure of a optimal solutio f M = (M M 2 M i ) (M i+ M i+2 M ) is a optimal solutio the : (M M 2 M i ) is a optimal solutio for M M i ND (M i+ M i+2 M ) is a optimal solutio for M i+ M For i j,, m[i, j] deotes the optimal solutio for the product M i M i+ M j m[i,j] = (i = j) mi { m[i,k] + m[k +, j] + d i- d k d j } (i < j) i<k<j T() k (T(k) T( k) O()) ( 2 ) Dr. Nejib Zaguia C563-W4 8 Dyamic Programmig Dyamic programmig approach How to compute m[, 6]? m [ i, j ] mi { m[i, k] m[k, j] d d d } i - k j i k < j x x x x x 2 x x x x 3 x x x 4 x x 5 x 6 olutio m[,6] Dr. Nejib Zaguia C563-W4 9 3

4 Dyamic Programmig Matrix-Chai-Order( p, ) { for i = to m[i,i] = for le = 2 to for i = to - le + j = i + le - m[i,j] = 8 for k = i to j- q = m[i,k] + m[k+,j] + d[i-]*d[k]*d[j] if q < m[i,j] the m[i,j] = q s[i,j] = k retur s } Dr. Nejib Zaguia C563-W4 Dyamic Programmig hortest path: Floyd algorithm Let G = (V,) be a coected weighted graph, fid all shortest paths betwee ay two vertices i G. tructure of a optimal solutio: f a shortest path betwee ad B cotais a vertex C the the sub paths betwee ad C ad betwee C ad B are optimal C B 5 3 B 2 5 C D 5 Dr. Nejib Zaguia C563-W4 Dyamic Programmig The algorithm: We maitai a 2 dimesioal array D (iitialized with L). Vertices of the graph are umbered from to. There are iteratios. fter iteratio k, D will cotai the shortest paths betwee ay two vertices (i, j), usig oly vertices from the set {, 2,, k}. t iteratio k ad for every pair of vertices (i, j) we check whether or ot the itroductio of vertex k will give a better shortest path. Phase k: L = D, D,.D = D Case. ddig vertex k does ot give a better solutio: Dk [i,j] = Dk-[i,j] Case 2. ll shortest paths betwee i ad j usig the vertices {, 2,, k} use the vertex k as a itermediary vertex. i Dk [i,j] = Dk-[i,k]+ Dk-[k,j]} Dk[i,j] = mi ( Dk-[i,j], Dk-[i,k] + Dk-[k,j] ) We eed a secod 2 dimesioal array P i order to keep track of the actual shortest path betwee ay two vertices: if D[i,k]+D[k,i] < D[i,j] the D[i,j] = D[i,k]+D[k,i] P[i,j] = k k j Dr. Nejib Zaguia C563-W4 2 4

5 Dyamic Programmig xample: D =L D B D D C 5 Dr. Nejib Zaguia C563-W4 3 Dyamic Programmig Cot D 2 D P D=D Dr. Nejib Zaguia C563-W4 4 Dyamic Programmig Floyd(, L[ ] [ ], P[ ][ ]) array D of size x array P of size x D = L; P= for(k=; k<=; k++) for(i=; i<=; i++) for(j=; j<=; j++) if D[i,k]+D[k,j] < D[i,j] D[i,j] = D[i,k]+D[k,j] P[i, j] = k retur D O( 3 ) Costat Dr. Nejib Zaguia C563-W4 5 5

6 Problem: Makig chage for cets usig the least umber of cois. Greedy algorithm: t each step, retur the largest possible coi xample : Cois: 25c c 5c c Makig chage of 87c: 3 x 25c + x c + 2 x c xample 2: Cois: 25c c 2c 5c c Makig chage of 6c: x 2c + 4 x c (Optimal solutio: x c + x 5c + x c (3 cois)) fuctio chage(c: set {cois}; s: iteger): set with repititios := {solutio} while s > do p := largest coi i C such that its value does ot exceed s; := {p} s := s-p retur Dr. Nejib Zaguia C563-W4 6 greedy algorithm go through a sequece of steps with a set of choices at each step. t makes the choice that looks best at the momet. Greedy algorithms are usually simple ad easy to implemet. Typically used for optimizatio problems. Greedy algorithms do ot always lead to a optimal solutio Geeral cheme of a greedy algorithm: C: set of cadidates := while is ot a solutio ad C x := elemet i C that maximizes the selectio criteria C := C - x if ( {x}) is realizable the := {x} if is a solutio the retur else retur o-solutio Dr. Nejib Zaguia C563-W4 7 Greedy algorithm for a task schedulig problem: miimizig the total waitig time. We have a set of tasks {, 2,, } to be processed sequetially by a sigle processor. ach task has a processig time ti. The goal is to miimize the total waitig time of all tasks (time spet by cliet i i the system: from start to fiishig of task i) i= xample: 3 tasks t = 5 There are 6 possible orders: t 2 = 23: 5 + (5 + ) + ( ) = 38 32: 5 + (5 + 3) + ( ) = 3 t 23: + ( + 5) + ( ) = 43 3 = 3 23: + ( + 3) + ( ) = 4 32: 3 + (3 + 5) + ( ) = 29 32: 3 + (3 + ) + ( ) = 34 Dr. Nejib Zaguia C563-W4 8 6

7 Greedy algorithm: at each step we choose a task, amog the oes left, with a miimum processig time. Theorem. The greedy algorithm always lead to a optimal schedulig Proof. Let = (i,i 2,,i ) a arbitrary permutatio of the tasks {,2,, }. f the tasks are scheduled accordig to the order the the total waitig time is: T() = t i + (t i + t i2 ) + (t i + t i2 + t i3 ) +.. uppose : a... b. k= where a < b ad t ia > t ib f we iverse the positios of a ad b i : b... a. ti ti2...tib...tia. ti Dr. Nejib Zaguia C563-W4 9 = ( - k + ) t ik T(') = ( - a + ) t ib + ( - b + ) t ia + ( - k + ) t ik k = k {a,b} Thus: T() = ( - k + ) t ik k= T(') = ( - a + ) t ib + ( - b + ) t ia + ( - k + ) t ik k = k {a,b} T() - T(') = ( - a + ) (t ia - t ib ) + ( - b + ) (t ib - t ia ) = (b-a) (t ia - t ib ) > Therefore the schedulig is better tha. Thus the greedy algorithm is always optimal, ad ay optimal solutio is ecessarily costructed usig the greedy algorithm. Dr. Nejib Zaguia C563-W4 2 other chedulig problem: uit-time tasks with deadlies ad pealties. set ={, 2,, } of uit-tasks. set of iteger deadlies d, d2,, d, such that di for each i, ad task i is supposed to fiish by time di set of o egative weights g, g2,, g such that a gai gi is icurred if task i is fiished by time di. i gi di The sequeces et, 2, 3 correspods to the same gai. Oly task leads to a gai. Possibles eq: gai ,3 65 2, 6 2,3 25 3, 65 4, 8 4,3 45 Dr. Nejib Zaguia C563-W4 2 7

8 set of tasks is realizable if there exists at least oe orderig of the tasks T that permits to all tasks i T to be executed before the delay. Theorem: set of tasks T is realizable if ad oly if all tasks of T are executed before the delay whe the tasks of T are sorted i icreasig order with respect to delay. Proof: ssume that is realizable with some order: t t2 ti tj tk with d(tj) < d(ti). By exchagig ti et tj i the order of we obviously obtai a realizable order: t t2 tj ti tk Repetitively, we obtai a icreasig order which is realizable. The coverse is obviously true. How do we kow if a set of tasks is realizable? t is eough to test the tasks i oe specific order: icreasig order with respect to delay. Dr. Nejib Zaguia C563-W4 22 : t each step, take the task ot cosidered yet, ad with the largest value gi. f the ew set of tasks is realizable, add that task to the solutio, otherwise disregard the task. ort the set of tasks i decreasig order T with respect to gai := O( log ) repeat Choose the task e T with the largest gai T := T - e f e is realizable := e util T is empty [(i-) + i] = 2 - i=2 Number of steps -. Need (i-) comparisos to add the ith task, i comparisos to verify that if the set is realizable Dr. Nejib Zaguia C563-W4 23 Huffma Code statistical compressio of data, it permits to reduce the legth of the codig of a alphabet. The Huffma code (952) is a optimal variable legth, that is the average legth of the coded text is miimal. We otice a size reductio of the order of 2 to 9%. Dr. Nejib Zaguia C563-W4 24 8

9 Codes with fixed legth: each character is coded with the same umber of bits. For C characters we eed log 2 C bits imple, ad easy to maipulate T B N T B N Dr. Nejib Zaguia C563-W4 25 xample 2 variable legth N T B T B N Dr. Nejib Zaguia C563-W4 26 xample 3 N B T TT = ymbol Code T B N Dr. Nejib Zaguia C563-W4 27 9

10 Char. T B N Frequecy Fixed legth Code Total Bits Variable legth Code Total Bits Dr. Nejib Zaguia C563-W4 28 codig should have the prefix property to avoid the ambiguity: a biary sequece caot be the code of a characters ad i the same time the start of the code of aother character. Prefix codes could be represeted by biary trees. Characters are placed as leafs ad the code is the readig of the uique path from the root to the leaf. Dr. Nejib Zaguia C563-W4 29 = Ou P T B N Prefixe!! ymbole Dr. Nejib Zaguia C563-W4 3 T B N P Code

11 Problem: put list of characters with frequecies. Output The biary tree for the variable legth code Total cost = s l s fs l s = umber of bits of the code of character s f s = frequecy of the character s Dr. Nejib Zaguia C563-W4 3 C 355 lgorithmes Voraces Huffma lgorithm(952) Greedy algorithm for variable legth optimal code The algorithm is of greedy type: costruct a loger path for a character with smaller frequecy. For each character we costruct a tree with a sigle vertex labelled with the frequecy of the character. t each stage of the algorithm, we merge the trees with the smallest labels o their root ito a ew tree with a ew root. The ew root is labelled with the sum of the labels of the old roots. The roots of the old trees become the left ad right child of the ew root. The algorithm eds whe we arrive to a uique tree. Dr. Nejib Zaguia C563-W T P L 9 T L T L 2 T T P T P Dr. Nejib Zaguia C563-W4 33

12 39 T3 T2 P T L T4 T T T L T2 39 T3 P 4 Dr. Nejib Zaguia C563-W T5 T3 T2 P T L 67 T4 T T2 T L 47 T6 T5 T4 T3 T P Dr. Nejib Zaguia C563-W4 35 Code 47 T6 T5 T4 T3 T T2 P T L ymbol Code T P L Dr. Nejib Zaguia C563-W4 36 2

13 T T P P L L Dr. Nejib Zaguia C563-W4 37 efficiet implemetatio: use heaps for vertices «priority list» Huffma (C) = umber of characters i C itializatio of the heap Q, (usig the frequecies as priority) for i i..- do z = ew vertex o tree x = xtract-miimum (Q) y = xtract-miimum (Q) left-child z = x log () right=child z = y f[z] = f[x] + f[y] sert (Q, z) ed for Retur tree O() Total Complexity: O( log) Dr. Nejib Zaguia C563-W4 38 other example: Dyamic Programmig Logest commo subsequece problem equeces X =<x, x2,..., xs> ad Y=<y, y2,..., yt> Z =<z, z2,..., zk> is a subsequece of X if there exists a strictly icreasig sequece <i(), i(2),..., i(k)> of idices of X such that for all j, x i(j) = z j <, C, Z, K> is a subsequece of <C,, F, C, C, Z, K, Y> with idex sequece <2, 4, 6, 7> or <2, 5, 6, 7> Z is a commo subsequece of X ad Y if Z is a subsequece of both X ad Y. X=<, B,C, B, D,, B> Y=<B, D, C,, B, > COMMON UBQUNC (C) B,C, logest C (LC) B, C, B, 2/3/25 Dr. Nejib Zaguia C563-W4 39 3

14 other example: Dyamic Programmig Brute force: try all commo subsequece takes expoetial time X =<x, x2,..., xi> Xi is the i-th prefix of X Theorem: Let Z=<z, z 2,..., z k > be ay LC of X ad Y. () f x s = y t the x k =x s =y t ad Z k- is a LC of X s- ad Y t- (2) f x s y t the z k x s implies that Z is a LC of X s- ad Y (3) f x s y t the z k y t implies that Z is a LC of X ad Y t- Dr. Nejib Zaguia C563-W4 4 other example: Dyamic Programmig Proof. () if z k x s, the we could apped x s =y t, to Z ad gets a C of legth k+. f there were a C W of X s- ad Y t- with legth k, the we could apped x s =y t to W ad get a C of X ad Y of legth k+. Thus, a C of X s- ad Y t- with legth k is a LC i.e. Zk- is a LC of X s- ad Y t- X q Xs- q Y q Y q Z q W q (2) if z k x s, the that Z is a C of X s- ad Y. f there were a C W of X s- ad Y with legth greater tha k, the W would also be a C of X s ad Y. X q Xs- q Y Z (3) ame argumet as (2) r Y W Dr. Nejib Zaguia C563-W4 4 other example: Dyamic Programmig Recursive solutio for fidig LC of X ad Y f x s =y t the fid a LC of X s- ad Y t-, ad the apped x s =y t to this LC f x s y t the solve two problems: () Fid a LC of X s- ad Y; (2) fid a LC of X ad Y t- ; whichever of these two LC s is loger, that s a LC of X ad Y. c[i, j]=legth of a LC of the sequeces X i ad Y j whe i= or j= the c[i, j] = whe i>, j>, ad x i =y j the c[i, j]= c[i-, j-]+ whe i>, j> ad x i y j the c[i, j] = max {c[i, j-], c[i-, j]} Complexity: O(st) Dr. Nejib Zaguia C563-W4 42 4

15 other example: Dyamic Programmig LC-Legth(X, Y) set c[i, ] s ad c[, j] s to for i= to s for j= to t if x i =x j the c[i, j] = c[i-, j-]+ else c[i, j]=max{ c[i, j-], c[i-, j]} Dr. Nejib Zaguia C563-W4 43 Greedy vs. Dyamic Programmig - kapsack problem thief robbig a store fids items i-th item has weight w[i] ad is worth v[i] dollars (w[i] ad v[i] are itegers). f the thief ca carry at most L weight i his kapsak, what items should he take to make the most profitable heist? Fractioal kapsack problem: same as above, except that the thief ca take fractios of items (e.g. a item might be gold dust) Dr. Nejib Zaguia C563-W4 44 Greedy vs. Dyamic Programmig Optimal substructures property: Cosider the most valuable load that weights L pouds i - problem, if we remove item j from this load, the remaiig load must be the most valuable load weightig at most L=w[j] that ca be take from the - origial items excludig j. fractioal problem, if we remove w pouds of item j, the remaiig load must be the most valuable load weightig at L=w that ca be take from the - origial items plus w[j] w pouds of item j. Dr. Nejib Zaguia C563-W4 45 5

16 Greedy vs. Dyamic Programmig greedy solutio for the fractioal problem Compute the v[i]/w[i] for each item i. ort i decreasig order the items accordig to the values of v[i]/w[i] For items i= to take as much of item as there while ot exceedig weight limit L Ruig time: O( log ) The same greedy algorithm does ot work for the - kapsack problem Dr. Nejib Zaguia C563-W4 46 tems Greedy vs. Dyamic Programmig Weight Gai tem 6 tem 2 tem 3 2 kapsack Greedy: 6 Optimal: 22 Take the most expesive does ot work: fails for L=3 Dyamic programmig solutio for - problem: ort items by icreasig weight. Let i be the highest-umbered item i a optimal solutio for a L kilo kapsack ad items... The =-{i} must be a optimal solutio for items..i- ad a L-w[i] kilos kapsacks. The value of solutio is v[i] plus the value of solutio. Let c[i, wj]=the value of the solutio for items..i ad maximum weight w whe i= or w= the c[i, w] = whe w[i] >w, the c[i, w]= c[i-, w] whe i> ad w w[i], the c[i, w] = max {v[i]+c[i-, w-w[i]], c[i-, w]} 2 Dr. Nejib Zaguia C563-W Greedy vs. Dyamic Programmig Dyamic --Kapsack: for w= to L c[, w]= for i= to c[i, ]= for w= to L if w[i] w the if v[i] + c[i-, w-w[i]] > c[i-, w] the c[i, w] = v[i] + c[i-, w-w[i]] else c[i, w]=c[i-, w] else c[i, w] = c[i-, w] Complexity: O(L) Dr. Nejib Zaguia C563-W4 48 6

Matrix Multiplication. Data Structures and Algorithms Andrei Bulatov

Matrix Multiplication. Data Structures and Algorithms Andrei Bulatov Matrix Multiplicatio Data Structures ad Algorithms Adrei Bulatov Algorithms Matrix Multiplicatio 7- Matrix Multiplicatio Matrix multiplicatio. Give two -by- matrices A ad B, compute A B. k kj ik ij b a

More information

CS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2

CS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2 Geeral remarks Week 2 1 Divide ad First we cosider a importat tool for the aalysis of algorithms: Big-Oh. The we itroduce a importat algorithmic paradigm:. We coclude by presetig ad aalysig two examples.

More information

Dynamic Programming. Sequence Of Decisions

Dynamic Programming. Sequence Of Decisions Dyamic Programmig Sequece of decisios. Problem state. Priciple of optimality. Dyamic Programmig Recurrece Equatios. Solutio of recurrece equatios. Sequece Of Decisios As i the greedy method, the solutio

More information

Dynamic Programming. Sequence Of Decisions. 0/1 Knapsack Problem. Sequence Of Decisions

Dynamic Programming. Sequence Of Decisions. 0/1 Knapsack Problem. Sequence Of Decisions Dyamic Programmig Sequece Of Decisios Sequece of decisios. Problem state. Priciple of optimality. Dyamic Programmig Recurrece Equatios. Solutio of recurrece equatios. As i the greedy method, the solutio

More information

2 DD2458 Popup HT Solution: Choose the activity which ends first and does not conflict with earlier chosen activities.

2 DD2458 Popup HT Solution: Choose the activity which ends first and does not conflict with earlier chosen activities. DD2458, Problem Solvig ad Programmig Uder Pressure Lecture 1: Greedy algorithms ad dyamic programmig Date: 2008-09-01 Scribe(s: Marti Wedi ad Nilas Wagre Lecturer: Douglas Wiström This lecture cotais basic

More information

4.3 Growth Rates of Solutions to Recurrences

4.3 Growth Rates of Solutions to Recurrences 4.3. GROWTH RATES OF SOLUTIONS TO RECURRENCES 81 4.3 Growth Rates of Solutios to Recurreces 4.3.1 Divide ad Coquer Algorithms Oe of the most basic ad powerful algorithmic techiques is divide ad coquer.

More information

Data Structures Lecture 9

Data Structures Lecture 9 Fall 2017 Fag Yu Software Security Lab. Dept. Maagemet Iformatio Systems, Natioal Chegchi Uiversity Data Structures Lecture 9 Midterm o Dec. 7 (9:10-12:00am, 106) Lec 1-9, TextBook Ch1-8, 11,12 How to

More information

Sorting Algorithms. Algorithms Kyuseok Shim SoEECS, SNU.

Sorting Algorithms. Algorithms Kyuseok Shim SoEECS, SNU. Sortig Algorithms Algorithms Kyuseo Shim SoEECS, SNU. Desigig Algorithms Icremetal approaches Divide-ad-Coquer approaches Dyamic programmig approaches Greedy approaches Radomized approaches You are ot

More information

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 17 Lecturer: David Wagner April 3, Notes 17 for CS 170

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 17 Lecturer: David Wagner April 3, Notes 17 for CS 170 UC Berkeley CS 170: Efficiet Algorithms ad Itractable Problems Hadout 17 Lecturer: David Wager April 3, 2003 Notes 17 for CS 170 1 The Lempel-Ziv algorithm There is a sese i which the Huffma codig was

More information

Recursive Algorithm for Generating Partitions of an Integer. 1 Preliminary

Recursive Algorithm for Generating Partitions of an Integer. 1 Preliminary Recursive Algorithm for Geeratig Partitios of a Iteger Sug-Hyuk Cha Computer Sciece Departmet, Pace Uiversity 1 Pace Plaza, New York, NY 10038 USA scha@pace.edu Abstract. This article first reviews the

More information

w (1) ˆx w (1) x (1) /ρ and w (2) ˆx w (2) x (2) /ρ.

w (1) ˆx w (1) x (1) /ρ and w (2) ˆx w (2) x (2) /ρ. 2 5. Weighted umber of late jobs 5.1. Release dates ad due dates: maximimizig the weight of o-time jobs Oce we add release dates, miimizig the umber of late jobs becomes a sigificatly harder problem. For

More information

Merge and Quick Sort

Merge and Quick Sort Merge ad Quick Sort Merge Sort Merge Sort Tree Implemetatio Quick Sort Pivot Item Radomized Quick Sort Adapted from: Goodrich ad Tamassia, Data Structures ad Algorithms i Java, Joh Wiley & So (1998). Ruig

More information

Divide & Conquer. Divide-and-conquer algorithms. Conventional product of polynomials. Conventional product of polynomials.

Divide & Conquer. Divide-and-conquer algorithms. Conventional product of polynomials. Conventional product of polynomials. Divide-ad-coquer algorithms Divide & Coquer Strategy: Divide the problem ito smaller subproblems of the same type of problem Solve the subproblems recursively Combie the aswers to solve the origial problem

More information

CSE 4095/5095 Topics in Big Data Analytics Spring 2017; Homework 1 Solutions

CSE 4095/5095 Topics in Big Data Analytics Spring 2017; Homework 1 Solutions CSE 09/09 Topics i ig Data Aalytics Sprig 2017; Homework 1 Solutios Note: Solutios to problems,, ad 6 are due to Marius Nicolae. 1. Cosider the followig algorithm: for i := 1 to α log e do Pick a radom

More information

Section 5.1 The Basics of Counting

Section 5.1 The Basics of Counting 1 Sectio 5.1 The Basics of Coutig Combiatorics, the study of arragemets of objects, is a importat part of discrete mathematics. I this chapter, we will lear basic techiques of coutig which has a lot of

More information

Chapter 22 Developing Efficient Algorithms

Chapter 22 Developing Efficient Algorithms Chapter Developig Efficiet Algorithms 1 Executig Time Suppose two algorithms perform the same task such as search (liear search vs. biary search). Which oe is better? Oe possible approach to aswer this

More information

A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence

A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence Sequeces A sequece of umbers is a fuctio whose domai is the positive itegers. We ca see that the sequece,, 2, 2, 3, 3,... is a fuctio from the positive itegers whe we write the first sequece elemet as

More information

IP Reference guide for integer programming formulations.

IP Reference guide for integer programming formulations. IP Referece guide for iteger programmig formulatios. by James B. Orli for 15.053 ad 15.058 This documet is iteded as a compact (or relatively compact) guide to the formulatio of iteger programs. For more

More information

This Lecture. Divide and Conquer. Merge Sort: Algorithm. Merge Sort Algorithm. MergeSort (Example) - 1. MergeSort (Example) - 2

This Lecture. Divide and Conquer. Merge Sort: Algorithm. Merge Sort Algorithm. MergeSort (Example) - 1. MergeSort (Example) - 2 This Lecture Divide-ad-coquer techique for algorithm desig. Example the merge sort. Writig ad solvig recurreces Divide ad Coquer Divide-ad-coquer method for algorithm desig: Divide: If the iput size is

More information

THE ASYMPTOTIC COMPLEXITY OF MATRIX REDUCTION OVER FINITE FIELDS

THE ASYMPTOTIC COMPLEXITY OF MATRIX REDUCTION OVER FINITE FIELDS THE ASYMPTOTIC COMPLEXITY OF MATRIX REDUCTION OVER FINITE FIELDS DEMETRES CHRISTOFIDES Abstract. Cosider a ivertible matrix over some field. The Gauss-Jorda elimiatio reduces this matrix to the idetity

More information

Markov Decision Processes

Markov Decision Processes Markov Decisio Processes Defiitios; Statioary policies; Value improvemet algorithm, Policy improvemet algorithm, ad liear programmig for discouted cost ad average cost criteria. Markov Decisio Processes

More information

HOMEWORK 2 SOLUTIONS

HOMEWORK 2 SOLUTIONS HOMEWORK SOLUTIONS CSE 55 RANDOMIZED AND APPROXIMATION ALGORITHMS 1. Questio 1. a) The larger the value of k is, the smaller the expected umber of days util we get all the coupos we eed. I fact if = k

More information

) n. ALG 1.3 Deterministic Selection and Sorting: Problem P size n. Examples: 1st lecture's mult M(n) = 3 M ( È

) n. ALG 1.3 Deterministic Selection and Sorting: Problem P size n. Examples: 1st lecture's mult M(n) = 3 M ( È Algorithms Professor Joh Reif ALG 1.3 Determiistic Selectio ad Sortig: (a) Selectio Algorithms ad Lower Bouds (b) Sortig Algorithms ad Lower Bouds Problem P size fi divide ito subproblems size 1,..., k

More information

CS583 Lecture 02. Jana Kosecka. some materials here are based on E. Demaine, D. Luebke slides

CS583 Lecture 02. Jana Kosecka. some materials here are based on E. Demaine, D. Luebke slides CS583 Lecture 02 Jaa Kosecka some materials here are based o E. Demaie, D. Luebke slides Previously Sample algorithms Exact ruig time, pseudo-code Approximate ruig time Worst case aalysis Best case aalysis

More information

CS 332: Algorithms. Linear-Time Sorting. Order statistics. Slide credit: David Luebke (Virginia)

CS 332: Algorithms. Linear-Time Sorting. Order statistics. Slide credit: David Luebke (Virginia) 1 CS 332: Algorithms Liear-Time Sortig. Order statistics. Slide credit: David Luebke (Virgiia) Quicksort: Partitio I Words Partitio(A, p, r): Select a elemet to act as the pivot (which?) Grow two regios,

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Desig ad Aalysis of Algorithms Probabilistic aalysis ad Radomized algorithms Referece: CLRS Chapter 5 Topics: Hirig problem Idicatio radom variables Radomized algorithms Huo Hogwei 1 The hirig problem

More information

CSE 202 Homework 1 Matthias Springer, A Yes, there does always exist a perfect matching without a strong instability.

CSE 202 Homework 1 Matthias Springer, A Yes, there does always exist a perfect matching without a strong instability. CSE 0 Homework 1 Matthias Spriger, A9950078 1 Problem 1 Notatio a b meas that a is matched to b. a < b c meas that b likes c more tha a. Equality idicates a tie. Strog istability Yes, there does always

More information

Optimization Methods MIT 2.098/6.255/ Final exam

Optimization Methods MIT 2.098/6.255/ Final exam Optimizatio Methods MIT 2.098/6.255/15.093 Fial exam Date Give: December 19th, 2006 P1. [30 pts] Classify the followig statemets as true or false. All aswers must be well-justified, either through a short

More information

Parallel Vector Algorithms David A. Padua

Parallel Vector Algorithms David A. Padua Parallel Vector Algorithms 1 of 32 Itroductio Next, we study several algorithms where parallelism ca be easily expressed i terms of array operatios. We will use Fortra 90 to represet these algorithms.

More information

Classification of problem & problem solving strategies. classification of time complexities (linear, logarithmic etc)

Classification of problem & problem solving strategies. classification of time complexities (linear, logarithmic etc) Classificatio of problem & problem solvig strategies classificatio of time complexities (liear, arithmic etc) Problem subdivisio Divide ad Coquer strategy. Asymptotic otatios, lower boud ad upper boud:

More information

OPTIMAL ALGORITHMS -- SUPPLEMENTAL NOTES

OPTIMAL ALGORITHMS -- SUPPLEMENTAL NOTES OPTIMAL ALGORITHMS -- SUPPLEMENTAL NOTES Peter M. Maurer Why Hashig is θ(). As i biary search, hashig assumes that keys are stored i a array which is idexed by a iteger. However, hashig attempts to bypass

More information

Optimally Sparse SVMs

Optimally Sparse SVMs A. Proof of Lemma 3. We here prove a lower boud o the umber of support vectors to achieve geeralizatio bouds of the form which we cosider. Importatly, this result holds ot oly for liear classifiers, but

More information

Chimica Inorganica 3

Chimica Inorganica 3 himica Iorgaica Irreducible Represetatios ad haracter Tables Rather tha usig geometrical operatios, it is ofte much more coveiet to employ a ew set of group elemets which are matrices ad to make the rule

More information

Disjoint set (Union-Find)

Disjoint set (Union-Find) CS124 Lecture 7 Fall 2018 Disjoit set (Uio-Fid) For Kruskal s algorithm for the miimum spaig tree problem, we foud that we eeded a data structure for maitaiig a collectio of disjoit sets. That is, we eed

More information

CHAPTER 10 INFINITE SEQUENCES AND SERIES

CHAPTER 10 INFINITE SEQUENCES AND SERIES CHAPTER 10 INFINITE SEQUENCES AND SERIES 10.1 Sequeces 10.2 Ifiite Series 10.3 The Itegral Tests 10.4 Compariso Tests 10.5 The Ratio ad Root Tests 10.6 Alteratig Series: Absolute ad Coditioal Covergece

More information

Information Theory and Statistics Lecture 4: Lempel-Ziv code

Information Theory and Statistics Lecture 4: Lempel-Ziv code Iformatio Theory ad Statistics Lecture 4: Lempel-Ziv code Łukasz Dębowski ldebowsk@ipipa.waw.pl Ph. D. Programme 203/204 Etropy rate is the limitig compressio rate Theorem For a statioary process (X i)

More information

TEACHER CERTIFICATION STUDY GUIDE

TEACHER CERTIFICATION STUDY GUIDE COMPETENCY 1. ALGEBRA SKILL 1.1 1.1a. ALGEBRAIC STRUCTURES Kow why the real ad complex umbers are each a field, ad that particular rigs are ot fields (e.g., itegers, polyomial rigs, matrix rigs) Algebra

More information

Recursive Algorithms. Recurrences. Recursive Algorithms Analysis

Recursive Algorithms. Recurrences. Recursive Algorithms Analysis Recursive Algorithms Recurreces Computer Sciece & Egieerig 35: Discrete Mathematics Christopher M Bourke cbourke@cseuledu A recursive algorithm is oe i which objects are defied i terms of other objects

More information

Polynomial Multiplication and Fast Fourier Transform

Polynomial Multiplication and Fast Fourier Transform Polyomial Multiplicatio ad Fast Fourier Trasform Com S 477/577 Notes Ya-Bi Jia Sep 19, 2017 I this lecture we will describe the famous algorithm of fast Fourier trasform FFT, which has revolutioized digital

More information

A representation approach to the tower of Hanoi problem

A representation approach to the tower of Hanoi problem Uiversity of Wollogog Research Olie Departmet of Computig Sciece Workig Paper Series Faculty of Egieerig ad Iformatio Scieces 98 A represetatio approach to the tower of Haoi problem M. C. Er Uiversity

More information

Foundations of Computer Science Lecture 13 Counting

Foundations of Computer Science Lecture 13 Counting Foudatios of Computer Sciece Lecture 3 Coutig Coutig Sequeces Build-Up Coutig Coutig Oe Set by Coutig Aother: Bijectio Permutatios ad Combiatios Last Time Be careful of what you read i the media: sex i

More information

Solutions for the Exam 9 January 2012

Solutions for the Exam 9 January 2012 Mastermath ad LNMB Course: Discrete Optimizatio Solutios for the Exam 9 Jauary 2012 Utrecht Uiversity, Educatorium, 15:15 18:15 The examiatio lasts 3 hours. Gradig will be doe before Jauary 23, 2012. Studets

More information

Integer Programming (IP)

Integer Programming (IP) Iteger Programmig (IP) The geeral liear mathematical programmig problem where Mied IP Problem - MIP ma c T + h Z T y A + G y + y b R p + vector of positive iteger variables y vector of positive real variables

More information

Sequences A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence

Sequences A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence Sequeces A sequece of umbers is a fuctio whose domai is the positive itegers. We ca see that the sequece 1, 1, 2, 2, 3, 3,... is a fuctio from the positive itegers whe we write the first sequece elemet

More information

1 of 7 7/16/2009 6:06 AM Virtual Laboratories > 6. Radom Samples > 1 2 3 4 5 6 7 6. Order Statistics Defiitios Suppose agai that we have a basic radom experimet, ad that X is a real-valued radom variable

More information

6.867 Machine learning, lecture 7 (Jaakkola) 1

6.867 Machine learning, lecture 7 (Jaakkola) 1 6.867 Machie learig, lecture 7 (Jaakkola) 1 Lecture topics: Kerel form of liear regressio Kerels, examples, costructio, properties Liear regressio ad kerels Cosider a slightly simpler model where we omit

More information

Lecture 10: Universal coding and prediction

Lecture 10: Universal coding and prediction 0-704: Iformatio Processig ad Learig Sprig 0 Lecture 0: Uiversal codig ad predictio Lecturer: Aarti Sigh Scribes: Georg M. Goerg Disclaimer: These otes have ot bee subjected to the usual scrutiy reserved

More information

The Simplex algorithm: Introductory example. The Simplex algorithm: Introductory example (2)

The Simplex algorithm: Introductory example. The Simplex algorithm: Introductory example (2) Discrete Mathematics for Bioiformatics WS 07/08, G. W. Klau, 23. Oktober 2007, 12:21 1 The Simplex algorithm: Itroductory example The followig itroductio to the Simplex algorithm is from the book Liear

More information

Recurrence Relations

Recurrence Relations Recurrece Relatios Aalysis of recursive algorithms, such as: it factorial (it ) { if (==0) retur ; else retur ( * factorial(-)); } Let t be the umber of multiplicatios eeded to calculate factorial(). The

More information

Test One (Answer Key)

Test One (Answer Key) CS395/Ma395 (Sprig 2005) Test Oe Name: Page 1 Test Oe (Aswer Key) CS395/Ma395: Aalysis of Algorithms This is a closed book, closed otes, 70 miute examiatio. It is worth 100 poits. There are twelve (12)

More information

Generalized Semi- Markov Processes (GSMP)

Generalized Semi- Markov Processes (GSMP) Geeralized Semi- Markov Processes (GSMP) Summary Some Defiitios Markov ad Semi-Markov Processes The Poisso Process Properties of the Poisso Process Iterarrival times Memoryless property ad the residual

More information

(A sequence also can be thought of as the list of function values attained for a function f :ℵ X, where f (n) = x n for n 1.) x 1 x N +k x N +4 x 3

(A sequence also can be thought of as the list of function values attained for a function f :ℵ X, where f (n) = x n for n 1.) x 1 x N +k x N +4 x 3 MATH 337 Sequeces Dr. Neal, WKU Let X be a metric space with distace fuctio d. We shall defie the geeral cocept of sequece ad limit i a metric space, the apply the results i particular to some special

More information

Randomized Algorithms I, Spring 2018, Department of Computer Science, University of Helsinki Homework 1: Solutions (Discussed January 25, 2018)

Randomized Algorithms I, Spring 2018, Department of Computer Science, University of Helsinki Homework 1: Solutions (Discussed January 25, 2018) Radomized Algorithms I, Sprig 08, Departmet of Computer Sciece, Uiversity of Helsiki Homework : Solutios Discussed Jauary 5, 08). Exercise.: Cosider the followig balls-ad-bi game. We start with oe black

More information

Analysis of Algorithms -Quicksort-

Analysis of Algorithms -Quicksort- Aalysis of Algorithms -- Adreas Ermedahl MRTC (Mälardales Real-Time Research Ceter) adreas.ermedahl@mdh.se Autum 2004 Proposed by C.A.R. Hoare i 962 Worst- case ruig time: Θ( 2 ) Expected ruig time: Θ(

More information

CSE 191, Class Note 05: Counting Methods Computer Sci & Eng Dept SUNY Buffalo

CSE 191, Class Note 05: Counting Methods Computer Sci & Eng Dept SUNY Buffalo Coutig Methods CSE 191, Class Note 05: Coutig Methods Computer Sci & Eg Dept SUNY Buffalo c Xi He (Uiversity at Buffalo CSE 191 Discrete Structures 1 / 48 Need for Coutig The problem of coutig the umber

More information

Problem Set 2 Solutions

Problem Set 2 Solutions CS271 Radomess & Computatio, Sprig 2018 Problem Set 2 Solutios Poit totals are i the margi; the maximum total umber of poits was 52. 1. Probabilistic method for domiatig sets 6pts Pick a radom subset S

More information

Week 5-6: The Binomial Coefficients

Week 5-6: The Binomial Coefficients Wee 5-6: The Biomial Coefficiets March 6, 2018 1 Pascal Formula Theorem 11 (Pascal s Formula For itegers ad such that 1, ( ( ( 1 1 + 1 The umbers ( 2 ( 1 2 ( 2 are triagle umbers, that is, The petago umbers

More information

Lecture 11: Pseudorandom functions

Lecture 11: Pseudorandom functions COM S 6830 Cryptography Oct 1, 2009 Istructor: Rafael Pass 1 Recap Lecture 11: Pseudoradom fuctios Scribe: Stefao Ermo Defiitio 1 (Ge, Ec, Dec) is a sigle message secure ecryptio scheme if for all uppt

More information

Introduction to Computational Biology Homework 2 Solution

Introduction to Computational Biology Homework 2 Solution Itroductio to Computatioal Biology Homework 2 Solutio Problem 1: Cocave gap pealty fuctio Let γ be a gap pealty fuctio defied over o-egative itegers. The fuctio γ is called sub-additive iff it satisfies

More information

Model of Computation and Runtime Analysis

Model of Computation and Runtime Analysis Model of Computatio ad Rutime Aalysis Model of Computatio Model of Computatio Specifies Set of operatios Cost of operatios (ot ecessarily time) Examples Turig Machie Radom Access Machie (RAM) PRAM Map

More information

Lecture 4 February 16, 2016

Lecture 4 February 16, 2016 MIT 6.854/18.415: Advaced Algorithms Sprig 16 Prof. Akur Moitra Lecture 4 February 16, 16 Scribe: Be Eysebach, Devi Neal 1 Last Time Cosistet Hashig - hash fuctios that evolve well Radom Trees - routig

More information

Algorithm Analysis. Algorithms that are equally correct can vary in their utilization of computational resources

Algorithm Analysis. Algorithms that are equally correct can vary in their utilization of computational resources Algorithm Aalysis Algorithms that are equally correct ca vary i their utilizatio of computatioal resources time ad memory a slow program it is likely ot to be used a program that demads too much memory

More information

Simple Polygons of Maximum Perimeter Contained in a Unit Disk

Simple Polygons of Maximum Perimeter Contained in a Unit Disk Discrete Comput Geom (009) 1: 08 15 DOI 10.1007/s005-008-9093-7 Simple Polygos of Maximum Perimeter Cotaied i a Uit Disk Charles Audet Pierre Hase Frédéric Messie Received: 18 September 007 / Revised:

More information

Chapter 6. Advanced Counting Techniques

Chapter 6. Advanced Counting Techniques Chapter 6 Advaced Coutig Techiques 6.: Recurrece Relatios Defiitio: A recurrece relatio for the sequece {a } is a equatio expressig a i terms of oe or more of the previous terms of the sequece: a,a2,a3,,a

More information

Infinite Sequences and Series

Infinite Sequences and Series Chapter 6 Ifiite Sequeces ad Series 6.1 Ifiite Sequeces 6.1.1 Elemetary Cocepts Simply speakig, a sequece is a ordered list of umbers writte: {a 1, a 2, a 3,...a, a +1,...} where the elemets a i represet

More information

THE SOLUTION OF NONLINEAR EQUATIONS f( x ) = 0.

THE SOLUTION OF NONLINEAR EQUATIONS f( x ) = 0. THE SOLUTION OF NONLINEAR EQUATIONS f( ) = 0. Noliear Equatio Solvers Bracketig. Graphical. Aalytical Ope Methods Bisectio False Positio (Regula-Falsi) Fied poit iteratio Newto Raphso Secat The root of

More information

ACO Comprehensive Exam 9 October 2007 Student code A. 1. Graph Theory

ACO Comprehensive Exam 9 October 2007 Student code A. 1. Graph Theory 1. Graph Theory Prove that there exist o simple plaar triagulatio T ad two distict adjacet vertices x, y V (T ) such that x ad y are the oly vertices of T of odd degree. Do ot use the Four-Color Theorem.

More information

( ) = p and P( i = b) = q.

( ) = p and P( i = b) = q. MATH 540 Radom Walks Part 1 A radom walk X is special stochastic process that measures the height (or value) of a particle that radomly moves upward or dowward certai fixed amouts o each uit icremet of

More information

Definitions and Theorems. where x are the decision variables. c, b, and a are constant coefficients.

Definitions and Theorems. where x are the decision variables. c, b, and a are constant coefficients. Defiitios ad Theorems Remember the scalar form of the liear programmig problem, Miimize, Subject to, f(x) = c i x i a 1i x i = b 1 a mi x i = b m x i 0 i = 1,2,, where x are the decisio variables. c, b,

More information

6.3 Testing Series With Positive Terms

6.3 Testing Series With Positive Terms 6.3. TESTING SERIES WITH POSITIVE TERMS 307 6.3 Testig Series With Positive Terms 6.3. Review of what is kow up to ow I theory, testig a series a i for covergece amouts to fidig the i= sequece of partial

More information

Analysis of Algorithms. Introduction. Contents

Analysis of Algorithms. Introduction. Contents Itroductio The focus of this module is mathematical aspects of algorithms. Our mai focus is aalysis of algorithms, which meas evaluatig efficiecy of algorithms by aalytical ad mathematical methods. We

More information

Skip lists: A randomized dictionary

Skip lists: A randomized dictionary Discrete Math for Bioiformatics WS 11/12:, by A. Bocmayr/K. Reiert, 31. Otober 2011, 09:53 3001 Sip lists: A radomized dictioary The expositio is based o the followig sources, which are all recommeded

More information

Counting Well-Formed Parenthesizations Easily

Counting Well-Formed Parenthesizations Easily Coutig Well-Formed Parethesizatios Easily Pekka Kilpeläie Uiversity of Easter Filad School of Computig, Kuopio August 20, 2014 Abstract It is well kow that there is a oe-to-oe correspodece betwee ordered

More information

Polynomial identity testing and global minimum cut

Polynomial identity testing and global minimum cut CHAPTER 6 Polyomial idetity testig ad global miimum cut I this lecture we will cosider two further problems that ca be solved usig probabilistic algorithms. I the first half, we will cosider the problem

More information

SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES

SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES Read Sectio 1.5 (pages 5 9) Overview I Sectio 1.5 we lear to work with summatio otatio ad formulas. We will also itroduce a brief overview of sequeces,

More information

NICK DUFRESNE. 1 1 p(x). To determine some formulas for the generating function of the Schröder numbers, r(x) = a(x) =

NICK DUFRESNE. 1 1 p(x). To determine some formulas for the generating function of the Schröder numbers, r(x) = a(x) = AN INTRODUCTION TO SCHRÖDER AND UNKNOWN NUMBERS NICK DUFRESNE Abstract. I this article we will itroduce two types of lattice paths, Schröder paths ad Ukow paths. We will examie differet properties of each,

More information

MA131 - Analysis 1. Workbook 2 Sequences I

MA131 - Analysis 1. Workbook 2 Sequences I MA3 - Aalysis Workbook 2 Sequeces I Autum 203 Cotets 2 Sequeces I 2. Itroductio.............................. 2.2 Icreasig ad Decreasig Sequeces................ 2 2.3 Bouded Sequeces..........................

More information

Rank Modulation with Multiplicity

Rank Modulation with Multiplicity Rak Modulatio with Multiplicity Axiao (Adrew) Jiag Computer Sciece ad Eg. Dept. Texas A&M Uiversity College Statio, TX 778 ajiag@cse.tamu.edu Abstract Rak modulatio is a scheme that uses the relative order

More information

COMP26120: More on the Complexity of Recursive Programs (2018/19) Lucas Cordeiro

COMP26120: More on the Complexity of Recursive Programs (2018/19) Lucas Cordeiro COMP26120: More o the Complexity of Recursive Programs (2018/19) Lucas Cordeiro lucas.cordeiro@machester.ac.uk Divide-ad-Coquer (Recurrece) Textbook: Algorithm Desig ad Applicatios, Goodrich, Michael T.

More information

Weakly Connected Closed Geodetic Numbers of Graphs

Weakly Connected Closed Geodetic Numbers of Graphs Iteratioal Joural of Mathematical Aalysis Vol 10, 016, o 6, 57-70 HIKARI Ltd, wwwm-hikaricom http://dxdoiorg/101988/ijma01651193 Weakly Coected Closed Geodetic Numbers of Graphs Rachel M Pataga 1, Imelda

More information

Permutations & Combinations. Dr Patrick Chan. Multiplication / Addition Principle Inclusion-Exclusion Principle Permutation / Combination

Permutations & Combinations. Dr Patrick Chan. Multiplication / Addition Principle Inclusion-Exclusion Principle Permutation / Combination Discrete Mathematic Chapter 3: C outig 3. The Basics of Coutig 3.3 Permutatios & Combiatios 3.5 Geeralized Permutatios & Combiatios 3.6 Geeratig Permutatios & Combiatios Dr Patrick Cha School of Computer

More information

Real Variables II Homework Set #5

Real Variables II Homework Set #5 Real Variables II Homework Set #5 Name: Due Friday /0 by 4pm (at GOS-4) Istructios: () Attach this page to the frot of your homework assigmet you tur i (or write each problem before your solutio). () Please

More information

CS / MCS 401 Homework 3 grader solutions

CS / MCS 401 Homework 3 grader solutions CS / MCS 401 Homework 3 grader solutios assigmet due July 6, 016 writte by Jāis Lazovskis maximum poits: 33 Some questios from CLRS. Questios marked with a asterisk were ot graded. 1 Use the defiitio of

More information

Algorithms Design & Analysis. Divide & Conquer

Algorithms Design & Analysis. Divide & Conquer Algorithms Desig & Aalysis Divide & Coquer Recap Direct-accessible table Hash tables Hash fuctios Uiversal hashig Perfect Hashig Ope addressig 2 Today s topics The divide-ad-coquer desig paradigm Revised

More information

CSE Introduction to Parallel Processing. Chapter 3. Parallel Algorithm Complexity

CSE Introduction to Parallel Processing. Chapter 3. Parallel Algorithm Complexity Dr. Izadi CSE-40533 Itroductio to Parallel Processig Chapter 3 Parallel Algorithm Complexity Review algorithm complexity ad various complexity classes Itroduce the otios of time ad time-cost optimality

More information

ROLL CUTTING PROBLEMS UNDER STOCHASTIC DEMAND

ROLL CUTTING PROBLEMS UNDER STOCHASTIC DEMAND Pacific-Asia Joural of Mathematics, Volume 5, No., Jauary-Jue 20 ROLL CUTTING PROBLEMS UNDER STOCHASTIC DEMAND SHAKEEL JAVAID, Z. H. BAKHSHI & M. M. KHALID ABSTRACT: I this paper, the roll cuttig problem

More information

# fixed points of g. Tree to string. Repeatedly select the leaf with the smallest label, write down the label of its neighbour and remove the leaf.

# fixed points of g. Tree to string. Repeatedly select the leaf with the smallest label, write down the label of its neighbour and remove the leaf. Combiatorics Graph Theory Coutig labelled ad ulabelled graphs There are 2 ( 2) labelled graphs of order. The ulabelled graphs of order correspod to orbits of the actio of S o the set of labelled graphs.

More information

Induction: Solutions

Induction: Solutions Writig Proofs Misha Lavrov Iductio: Solutios Wester PA ARML Practice March 6, 206. Prove that a 2 2 chessboard with ay oe square removed ca always be covered by shaped tiles. Solutio : We iduct o. For

More information

Lecture 9: Hierarchy Theorems

Lecture 9: Hierarchy Theorems IAS/PCMI Summer Sessio 2000 Clay Mathematics Udergraduate Program Basic Course o Computatioal Complexity Lecture 9: Hierarchy Theorems David Mix Barrigto ad Alexis Maciel July 27, 2000 Most of this lecture

More information

Quantum Computing Lecture 7. Quantum Factoring

Quantum Computing Lecture 7. Quantum Factoring Quatum Computig Lecture 7 Quatum Factorig Maris Ozols Quatum factorig A polyomial time quatum algorithm for factorig umbers was published by Peter Shor i 1994. Polyomial time meas that the umber of gates

More information

Fortgeschrittene Datenstrukturen Vorlesung 11

Fortgeschrittene Datenstrukturen Vorlesung 11 Fortgeschrittee Datestruture Vorlesug 11 Schriftführer: Marti Weider 19.01.2012 1 Succict Data Structures (ctd.) 1.1 Select-Queries A slightly differet approach, compared to ra, is used for select. B represets

More information

Beurling Integers: Part 2

Beurling Integers: Part 2 Beurlig Itegers: Part 2 Isomorphisms Devi Platt July 11, 2015 1 Prime Factorizatio Sequeces I the last article we itroduced the Beurlig geeralized itegers, which ca be represeted as a sequece of real umbers

More information

Hashing and Amortization

Hashing and Amortization Lecture Hashig ad Amortizatio Supplemetal readig i CLRS: Chapter ; Chapter 7 itro; Sectio 7.. Arrays ad Hashig Arrays are very useful. The items i a array are statically addressed, so that isertig, deletig,

More information

Langford s Problem. Moti Ben-Ari. Department of Science Teaching. Weizmann Institute of Science.

Langford s Problem. Moti Ben-Ari. Department of Science Teaching. Weizmann Institute of Science. Lagford s Problem Moti Be-Ari Departmet of Sciece Teachig Weizma Istitute of Sciece http://www.weizma.ac.il/sci-tea/beari/ c 017 by Moti Be-Ari. This work is licesed uder the Creative Commos Attributio-ShareAlike

More information

Review Problems 1. ICME and MS&E Refresher Course September 19, 2011 B = C = AB = A = A 2 = A 3... C 2 = C 3 = =

Review Problems 1. ICME and MS&E Refresher Course September 19, 2011 B = C = AB = A = A 2 = A 3... C 2 = C 3 = = Review Problems ICME ad MS&E Refresher Course September 9, 0 Warm-up problems. For the followig matrices A = 0 B = C = AB = 0 fid all powers A,A 3,(which is A times A),... ad B,B 3,... ad C,C 3,... Solutio:

More information

Sequences and Series

Sequences and Series Sequeces ad Series Sequeces of real umbers. Real umber system We are familiar with atural umbers ad to some extet the ratioal umbers. While fidig roots of algebraic equatios we see that ratioal umbers

More information

Model of Computation and Runtime Analysis

Model of Computation and Runtime Analysis Model of Computatio ad Rutime Aalysis Model of Computatio Model of Computatio Specifies Set of operatios Cost of operatios (ot ecessarily time) Examples Turig Machie Radom Access Machie (RAM) PRAM Map

More information

Lecture 2: April 3, 2013

Lecture 2: April 3, 2013 TTIC/CMSC 350 Mathematical Toolkit Sprig 203 Madhur Tulsiai Lecture 2: April 3, 203 Scribe: Shubhedu Trivedi Coi tosses cotiued We retur to the coi tossig example from the last lecture agai: Example. Give,

More information

EE260: Digital Design, Spring n Binary Addition. n Complement forms. n Subtraction. n Multiplication. n Inputs: A 0, B 0. n Boolean equations:

EE260: Digital Design, Spring n Binary Addition. n Complement forms. n Subtraction. n Multiplication. n Inputs: A 0, B 0. n Boolean equations: EE260: Digital Desig, Sprig 2018 EE 260: Itroductio to Digital Desig Arithmetic Biary Additio Complemet forms Subtractio Multiplicatio Overview Yao Zheg Departmet of Electrical Egieerig Uiversity of Hawaiʻi

More information

ECEN 655: Advanced Channel Coding Spring Lecture 7 02/04/14. Belief propagation is exact on tree-structured factor graphs.

ECEN 655: Advanced Channel Coding Spring Lecture 7 02/04/14. Belief propagation is exact on tree-structured factor graphs. ECEN 655: Advaced Chael Codig Sprig 014 Prof. Hery Pfister Lecture 7 0/04/14 Scribe: Megke Lia 1 4-Cycles i Gallager s Esemble What we already kow: Belief propagatio is exact o tree-structured factor graphs.

More information