$OJRULWKPV. (Feodor F. Dragan) Department of Computer Science Kent State University

Size: px
Start display at page:

Download "$OJRULWKPV. (Feodor F. Dragan) Department of Computer Science Kent State University"

Transcription

1 $GYDQF $OJRULWKPV (Feodor F. Dragan) Department of Computer Scence Kent State Unversty Advanced Algorthms, Feodor F. Dragan, Kent State Unversty Textbook: Thomas Cormen, Charles Lesterson, Ronald Rvest, and Clff Sten, Introducton to Algorthms, McGraw Hll Publshng Company and MIT Press, (nd Edton). Gradng: Homework: 4% Mdterm Exam: 3% Fnal Exam: 3% All the course sldes wll be avalable at Advanced Algorthms, Feodor F. Dragan, Kent State Unversty

2 Course Outlne We wll cover the followng topcs (the topcs and order lsted are tentatve and subect to change; some topcs may only be quckly surveyed to add breadth, whle others wll be covered n reasonable depth). Dynamc Programmng Optmal greedy algorthms Amortzed analyss Parallel and crcut algorthms Network flow algorthms Randomzed algorthms Number theoretc & cryptographc algorthms Strng matchng algorthms Computatonal geometry algorthms Algorthms for NP-hard and NP-complete problems Approxmaton algorthms Onlne algorthms Lnear programmng algorthms Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 3 What s a computer program exactly? Input Some mysterous processng Output Programs = Data Structures + Algorthms Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 4

3 CHAPTER 5 Dynamc Programmng We begn dscusson of an mportant algorthm desgn technque, called dynamc programmng (or DP for short). It s not a partcular algorthm, t s a metatechnque. Programmng = tableau method, not wrtng a code. The technque s among the most powerful for desgnng algorthms for optmzaton problems. Ths s true for two reasons. Dynamc programmng solutons are based on a few common elements. Dynamc programmng problems are typcal optmzaton problems (fnd the mnmum or maxmum cost soluton, subect to varous constrants. The technque s related to dvde-and-conquer, n the sense that t breaks problems down nto smaller problems that t solves recursvely. However, because of the somewhat dfferent nature of dynamc programmng problems, standard dvde-and-conquer solutons are not usually effcent. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 5 The basc elements that characterze a dynamc programmng algorthm are: Substructure: Decompose your problem nto smaller (and hopefully smpler) subproblems. Express the soluton of the orgnal problem n terms of solutons for smaller problems. (Unlke dvde-and-conquer problems, t s not usually suffcent to consder one decomposton, but many dfferent ones.) Table-structure: Store the answers to the subproblems n a table. Ths s done because (typcally) subproblem solutons are reused many tmes, and we do not want to repeatedly solve the same problem. Bottom-up computaton: Combne solutons on smaller subproblems to solve larger subproblems, and eventually to arrve at a soluton to the complete problem. (Our text also dscusses a top-down alternatve, called memozaton.) Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 6 3

4 The most mportant queston n desgnng a DP soluton to a problem s how to set up the subproblem structure. Ths s called the formulaton of the problem. Dynamc programmng s not applcable to all optmzaton problems. There are two mportant elements that a problem must have n order for DP to be applcable. Optmal substructure: Optmal soluton to the problem contans wthn t optmal solutons to subproblems. Ths s sometmes called the prncple of optmalty. It states that for the global problem to be solved optmally, each subproblem should be solved optmally. Polynomally many subproblems: An mportant aspect to the effcency of DP s that the total number of dstnct subproblems to be solved should be at most a polynomal number. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 7 Strngs One mportant area of algorthm desgn s the study of algorthms for character strngs. There are a number of mportant problems here. Among the most mportant has to do wth effcently searchng for a substrng or generally a pattern n large pece of text. (Ths s what text edtors do when you perform a search.) In many nstances you do not want to fnd a pece of text exactly, but rather somethng that s smlar. Ths arses for example n genetcs research. Genetc codes are stored as long DNA molecules. The DNA strands conssts of a strng of molecules of four basc types: C, G, T, A. Exact matches rarely occur n bology because of small changes n DNA replcaton. For ths reason, t s of nterest to compute smlartes between strngs that do not match exactly. One common method of measurng the degree of smlarty between two strngs s to compute ther longest common subsequence. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 8 4

5 Longest Common Subsequence Gven two sequences of characters X = x, x,..., x m and Z = z, z,..., zk, we say that Z s a subsequence of X f there s a strctly ncreasng sequence of k ndces,..., ( < <... < ) such that Z = x, x,..., x. In X = ABRACADABRA, Z = AADAA, T = ADAD Z s a subsequence of X, T s not. Gven two strngs X and Y, the longest common subsequence (LCS) of X and Y s a longest sequence Z whch s both a subsequence of X and Y. The LCS of s Z =, k m k X = ABRACADABRA and Y = YABBADABBADOO ABADABA. k The longest common subsequence problem s the followng. Gven two sequences X = x, x,..., x m and Y = y, y,..., yn, determne a LCS of X and Y. It s not always unque. LCS of (ABC) and (BAC) s ether (AC) or (BC). Brute-force algorthm: (very neffcent) for every subsequence of X check f t s n Y. O( nm) tme ( m subseqences of X, O(n) for scannng Y wth X-subseq.) Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 9 Dynamc Programmng Approach In typcal DP fashon, we need to break the problem nto smaller peces. There are many ways to do ths for strngs. But t turns out for ths problem that consderng all pars of prefxes wll suffce for us. A prefx of a sequence s ust an ntal strng of values, X = x, x,..., x. s the empty sequence. X The dea wll be to compute the longest common subsequence for every possble par of prefxes ( polynomal (how many?) number of subproblems). Let c[] denote the length of the longest common subsequence of X and Y. Eventually we are nterested n c[m, n] snce ths wll be the LCS of the two entre strngs (where s the prncple of optmalty?). The dea s to compute c[ ] assumng that we already know the values of c[, ] for and (but not both equal). We begn wth some observatons. Bass: c[ ] = c[,] =. If ether sequence s empty, then the longest common subsequence s empty. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 5

6 Dynamc Programmng Approach (cont.) Last characters match: Suppose x = y. Snce both end n x, we clam that the LCS must also end n x. (We wll leave the proof as an exercse.) Snce the s part of the LCS we may fnd the overall LCS by removng x from both sequences and takng the LCS of X and Y, and then addng to the x end. Thus f x = y then c[ ] = c[, ] +. Last characters do not match: Suppose x y. In ths case x and y cannot both be n LCS (snce they would have to be the last character of the LCS). Thus ether x s not part of the LCS, or y s not part of the LCS (and possbly both are not part of the LCS). In the frst case the LCS of X and Y s the LCS of X and Y, whch s c[-,]. In the second case the LCS s the LCS of and Y, whch s c[-]. We do not know whch s the case, so we try both and take the one that gves us the longer LCS. Thus, f x y then c[ ] = max( c[, ], c[ ]). X Advanced Algorthms, Feodor F. Dragan, Kent State Unversty x Implementng the Rule Thus, c[ ] = max( c[, ], c[ ]) c[, ] + = or =, > and x y, > and x = y The task now s to smply mplement ths rule. We concentrate only on computng the maxmum length of the LCS. Later we wll see how to extract the actual sequence. We wll store some helpful ponters n a parallel array, b[..m,..n]. The code s shown below. LCS (char x[..m], char y[..n] ) { // compute LCS table nt c[..m,..n]; char b[..m,..n]; for = to m do {c[]=; b[]=skipx;} // ntalze column for = to n do {c[,]=; b[,]=skipy;} // ntalze row for = to m do { // fll rest of table for = to n do { f (x[]==y[]) {c[]=c[-,-]+; b[]=addxy; } // take x[] (=y[]) for LCS else f (c[-,]>=c[-]) { // x[] s not n LCS c[]=c[-,]; b[]=skipx;} else {c[]=c[-]; b[]=skipy;} } } // y[] s not n LCS return c[m,n]; } // return length of LCS Advanced Algorthms, Feodor F. Dragan, Kent State Unversty f f f. 6

7 Extractng the Actual Sequence Extractng the fnal LCS s done by usng the back ponters stored n b[..m,..n]. Intutvely b[ ] = ADDXY means that x[] and y [] together form the last character of the LCS. So, we take ths common character, and contnue wth entry b[-,-] to the northwest ( ). If b[]=skipx, then we know that x[] s not n the LCS, and we skp t and go to b[-,] ( ). Smlarly, f b[ ] = SKIPY, then we know that y[] s not n the LCS, and so we skp t and go to b[ ] to the left ( ). Followng these back ponters, and outputtng a character wth each dagonal move gves the fnal subsequence. getlcs (char x[..m], char y[..n], char b[..m,..n]) { // extract the LCS LCS=empty strng; =m; =n; // start at lower rght whle (!= &&!=) { // go untll upper left swtch b[] { case ADDXY: add x[] (or equvalently y[]) to front of LCS --; --; break case SKIPX: --; break // skp x[] case SKIPY: --; break } } // skp y[] return LCS } Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 3 Tme and Space Bounds and an Example The runnng tme of the algorthm LCS s clearly O(mn) snce there are two nested loops wth m and n teratons, respectvely. The runnng tme of the algorthm getlcs s O(m+n). Both algorthms use O(mn) space. X: 3 4 Y: 3 4 = n B D C B B A C D X=BACDB Y=BDCB LCS=BCB m= 5 B 3 m= 5 B Y: 3 4 = n B A C D B D C B LCS Length Table wth back ponters ncluded Longest common subsequence example. READ Ch. 5.4 n CLRS. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 4 7

8 Chan Matrx Multplcaton Ths problem nvolves the queston of determnng the optmal sequence for performng a seres of operatons. Ths general class of problem s mportant n compler desgn for code optmzaton and n databases for query optmzaton. We wll study the problem n a very restrcted nstance, where the dynamc programmng ssues are easest to see. Suppose that we wsh to multply a seres of matrces A A... A n Matrx multplcaton s an assocatve but not a commutatve operaton. Ths means that we are free to parenthesze the above multplcaton however we lke, but we are not free to rearrange the order of the matrces. Also recall that when two (non-square) matrces are beng multpled, there are restrctons on the dmensons. A matrx has p rows and q columns. You can multply a p q p matrx A tmes a q q r matrx B, and the result wll be a p r matrx C. The number of columns of A must equal the number of rows of B. In partcular, for p and r, A * B = C [, ] = q q C A[ k] B[ k, ]. p p k= r There are p r total entres n C and each r takes O(q) tme to compute, thus the total tme q (e.g. number of multplcatons) to multply these two matrces s p q r. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 5 Note that although any legal parentheszaton wll lead to a vald result, not all nvolve the same number of operatons. Consder the case of 3 matrces: Then Problem Formulaton A be 4, A be 4 6, A be multcost[((a A)A3)] = (5 4 6) + (5 6 ) = 8; multcost[(a ( A A ))] = (4 6 ) + (5 4 ) = Even for ths small example, consderable savngs can be acheved by reorderng the evaluaton sequence.. Chan Matrx Multplcaton Problem: Gven a sequence of matrces A A... A and dmensons p, p, p,..., p n n where A s of dmenson p p, determne the order of multplcaton that mnmzes the number of operatons. Important note: Ths algorthm does not perform the multplcatons, t ust fgures out the best order n whch to perform the multplcatons. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 6 8

9 Nave Algorthm We could wrte a procedure whch tres all possble parentheszatons. Unfortunately, the number of ways of parentheszng an expresson s very large. If you have ust one tem, then there s only one way to parenthesze. If you have n tems, then there are n- places where you could break the lst wth the outermost par of parentheses, namely ust after the frst tem, ust after the second tem, etc., and ust after the (n-)st tem. When we splt ust after the kth tem, we create two sublsts to be parentheszed, one wth k tems, and the other wth n-k tems. Then we could consder all the ways of parentheszng these. Snce these are ndependent choces, f there are L ways to parenthesze the left sublst and R ways to parenthesze the rght sublst, then the total s L tmes R. Ths suggests the followng recurrence for P(n), the number of dfferent ways of parentheszng n tems: f n =, P( n) = n P( k) P( n k) f n. k= Ths s related to famous functon n combnatorcs called the Catalan numbers (whch n turn s related to the number of dfferent bnary trees on n nodes). In partcular P (n) = C(n-), where C(n) s the nth Catalan number; ( ) n C n =. n+ n Applyng Strlng s formula, we fnd that C( n) Ω(4n / n 3/ ). Snce 4n s exponental and n 3/ s ust polynomal, the exponental wll domnate, mplyng that functon grows very fast. Thus, ths wll not be practcal except for very small n. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 7 Dynamc Programmng Approach Ths problem, lke other dynamc programmng problems nvolves determnng a structure (n ths case, a parentheszaton). We want to break the problem nto subproblems, whose solutons can be combned to solve the global problem. For convenence we can wrte A.. to be the result of multplyng matrces through. It s easy to see that A s a p p.. matrx. In parentheszng the expresson, we can consder the hghest level of parentheszaton. At ths level we are smply multplyng two matrces together. That s, for any k, k n, A.. n = A.. k Ak +.. n. Thus the problem of determnng the optmal sequence of multplcatons s broken up nto two questons: how do we decde where to splt the chan (what s k?) and how do we parenthesze the subchans A..k and A k+.. n? The subchan problems can be solved by recursvely applyng the same scheme. So, let us thnk about the problem of determnng the best value of k. At ths pont, you may be tempted to consder some clever deas. For example: snce we want matrces wth small dmensons, pck the value of k that mnmzes p k. Although ths s not a bad dea, t turns out that t does not work n ths case. Instead, (as n almost all dynamc programmng solutons), we wll do the dumb thng. We wll consder all possble values of k, and take the best of them. Notce that ths problem satsfes the prncple of optmalty, because once we decde to break the sequence nto the product A.. k A k +.. n, we should compute each subsequence optmally. That s, for the global problem to be solved optmally, the subproblems must be solved optmally as well. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 8 9

10 Dynamc Programmng Formulaton We wll store the solutons to the subproblems n a table, and buld the table n a bottom-up manner. For n, let m[ ] denote the mnmum number of multplcatons needed to compute A... The optmum cost can be descrbed by the followng recursve formulaton. Bass: Observe that f = then the sequence contans only one matrx, and so the cost s. (There s nothng to multply.) Thus, m[ ] =. Step: If, then we are askng about the product. Ths can be splt by consderng each k, k n, as A. A.. A.. k k+.. The optmum tme to compute k s m[ k], and the optmum tme to compute k + s m[k +, ]. We may assume that these values have been computed prevously and stored n our array. Snce A.. s a p p k matrx, and A k k +.. s a p k p matrx, the tme to multply them s p p p. Ths suggests the followng recursve rule for computng m[ ]. k m[ ] =, k< m[ ] = mn ( m[ k] + m[ k +, ] + p p p ) k for <. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 9 A.. A.. Implementng the Rule It s not hard to convert ths rule nto a procedure, whch s gven below. The only trcky part s arrangng the order n whch to compute the values. In the process of computng m[ ] we wll need to access values m[ k] and m[k +, ] for k lyng between and. Ths suggests that we should organze our computaton accordng to the number of matrces n the subchan. Let L = -+ denote the length of the subchan beng multpled. The subchans of length (m[ ]) are trval. Then we buld up by computng the subchans of length, 3,, n. The fnal answer s m[,n]. We need to be a lttle careful n settng up the loops. If a subchan of length L starts at poston then = + L-. Snce we want n, ths means that +L- n, or n other words, n-l+. So our loop for runs from to n-l+ (to keep n bounds). Matrx-Chan(array p[..n], nt n) { array s[..n-,..n]; for = to n do m[]=; // ntalze for L= to n do { // L=length of subchan for = to n-l+ do { =+L-; m[]=nfnty; for k= to - do { // check all splts q=m[k]+m[k+,]+p[-]*p[k]*p[]; f (q<m[]) {m[]=q; s[]=k; } } } } return m[,n](fnal cost) and s (splttng markers); } The runnng tme of ths procedure s (3 nested loops, each terates n tmes.) Θ( n 3 ). Advanced Algorthms, Feodor F. Dragan, Kent State Unversty

11 Extractng Optmum Sequence The array s[ ] can be used to extract the actual sequence. To extract t s a farly easy extenson. The basc dea s to keep n s[] a splt marker ndcatng what the best splt s, that s, what value of k leads to the mnmum value of m[ ]. s[ ] = k tells us that the best way to multply the subchan A s to frst multply the subchan A.... k and then multply the subchan A, and fnally multply these k +.. together. Intutvely, s[ ] tells us what multplcaton to perform last. Note that we only need to store s[ ] when we have at least two matrces, that s, f >. The actual multplcaton algorthm uses the s[ ] value to determne how to splt the current sequence. Assume that the matrces are stored n an array of matrces A[..n], and that s[ ] s global to ths recursve procedure. The procedure returns a matrx. Mult() { f ( ==) return A[]; // basc case else { k=s[]; X=Mult(k]; // X=A[] A[k] Y=Mult(k+,]; // Y=A[k+] A[] return X*Y; // multply matrces X and Y } } Advanced Algorthms, Feodor F. Dragan, Kent State Unversty Chan Matrx Multplcaton Example Ths algorthm s trcky, so t would be a good dea to trace through ths example (and the one gven n the text). The ntal set of dmensons are 5; 4; 6; ; 7 meanng that we are multplyng A (5 4) tmes A (4 6) tmes A tmes 3 (6 ) A 4 ( 7) The optmal sequence s ((A(AA3))A4) A p A A A3 4 p p p 3 p4 m[] 3 s[] 3 A A A3 A4 READ Ch. 5. n CLRS. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty

12 Recursve Implementaton We have descrbed dynamc programmng as a method that nvolves the ``bottom-up'' computaton of a table. However, the recursve formulatons that we have derved have been set up n a ``top-down'' manner. Must the computaton proceed bottom-up? Consder the followng recursve mplementaton of the chan-matrx multplcaton algorthm. The call Rec-Matrx-Chan(p, ) computes and returns the value of m[ ]. The ntal call s Rec-Matrx-Chan(p,, n). We only consder the cost here. Rec-Matrx-Chan(array p, nt nt ) { f (==) m[]=; // basc case else { m[]=nfnty; // ntalze for k= to - do { // try all splts cost=rec-matrx-chan(p,k)+ Rec-Matrx-Chan(p,k+,)+p[-]*p[k]*p[]; f (cost<m[]) m[]=cost; } } // update f better return m[]; } // return fnal cost (Note that the table m[..n,..n] s not really needed. We show t ust to make the connecton wth the earler verson clearer.) Ths verson of the procedure certanly looks much smpler, and more closely resembles the recursve formulaton that we gave prevously for ths problem. So, what s wrong wth ths? Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 3 Clam: Recursve Implementaton (cont.) The answer s the runnng tme s much hgher than the Θ( n 3 ) algorthm that we gave before. In fact, we wll see that ts runnng tme s exponental n n. Ths s unacceptably slow. Let T(n) denote the runnng tme of ths algorthm on a sequence of matrces of length n. (That s, n = +.) If =, then we have a sequence of length, and the tme s Θ(). Otherwse, we do Θ() work and then consder all possble ways of splttng the sequence of length n nto two sequences, one of length k and the other of length n-k, and nvoke the procedure recursvely on each one. So, we get the followng recurrence, defned for n. (We have replaced the Θ() s wth the constant.) f n =, T( n) = n + ( T( k) + T ( n k)) f n. k = T( n) n Proof: By nducton on n. Clearly, ths s true for n=. The nducton hypothess s that for all m<n. Usng ths we have ( m) m n n - gnore the term T(n-k), T( n) = + ( T ( k) + T ( n k)) + ( ) = T k k k= - apply the nducton, and n k n k n n + = + = + ( ) =. - apply the formula for the geometrc seres. k= k= Why s ths so much worse than the dynamc programmng verson? If you ``unravel'' the recursve calls on a reasonably long example, you wll see that the procedure s called repeatedly wth the same arguments. The bottom-up verson evaluates each entry exactly once. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 4

13 Memozaton Is t possble to retan the nce top-down structure of the recursve soluton, whle keepng the same O( n 3 ) effcency of the bottom-up verson? The answer s yes, through a technque called memozaton. Here s the dea. Let's reconsder the functon Rec-Matrx-Chan() gven above. It's ob s to compute m[ ], and return ts value. As noted above, the man problem wth the procedure s that t recomputes the same entres over and over. So, we wll fx ths by allowng the procedure to compute each entry exactly once. One way to do ths s to ntalze every entry to some specal value (e.g. UNDEFINED). Once an entres value has been computed, t s never recomputed. Mem-Matrx-Chan(array p, nt nt ) { f (m[]!= UNDEFINED) return m[]; // already defned else f (==) m[]=; // basc case else { m[]=nfnty; // ntalze for k= to - do { // try all splts cost=mem-matrx-chan(p,k)+ Mem-Matrx-Chan(p,k+,)+p[-]*p[k]*p[]; f (cost<m[]) m[]=cost; } } // update f better return m[]; } // return fnal cost Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 5 Memozaton (cont.) Ths verson runs n O ( n 3 ) tme. Intutvely, ths s because each of the O( n ) table entres s only computed once, and the work needed to compute one table entry (most of t n the for-loop) s at most O(n).... Memozaton s not usually used n practce, snce t s generally slower than the bottom-up method. However, n some DP problems, many of the table entres are smply not needed, and so bottom-up computaton may compute entres that are never needed. In these cases memozaton may be a good dea. If you know that most of the table wll not be needed, here s a way to save space. Rather than storng the whole table explctly as an array, you can store the ``defned'' entres of the table n a hash table, usng the ndex par ( ) as the hash key. See Chapter n CLRS for more nformaton on hashng. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 6 3

14 Polygons and Trangulatons Let's consder a geometrc problem that outwardly appears to be qute dfferent from chan-matrx multplcaton, but actually has remarkable smlartes. We begn wth a number of defntons. Defne a polygon to be a pecewse lnear closed curve n the plane. In other words, we form a cycle by onng lne segments end to end. The lne segments are called the sdes of the polygon and the endponts are called the vertces. A polygon s smple f t does not cross tself, that s, f the sdes do not ntersect one another except for two consecutve sdes sharng a common vertex. A smple polygon subdvdes the plane nto ts nteror, ts boundary and ts exteror. A smple polygon s sad to be convex f every nteror angle s at most 8 degrees. Vertces wth nteror angle equal to 8 degrees are normally allowed, but for ths problem we wll assume that no such vertces exst. Polygon Smple Polygon Convex Polygon Gven a convex polygon, we assume that ts vertces are labeled n counterclockwse order P = v, v, v,..., vn. We assume that ndexng s done modulo n, so v = vn. Ths polygon has n sdes, v v. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 7 Trangulatons (cont.) Gven two non-adacent vertces v, v ( < ), the lne segment s a chord. (If the polygon s smple but not convex, we nclude the addtonal requrement v v that the nteror of the segment les entrely n the nteror of P. Any chord subdvdes the polygon nto two polygons: v v,..., v and v, v +,..., v A trangulaton of a convex polygon s a maxmal set T of parwse non-crossng chords. In other words, every chord that s not n T ntersects the nteror of some chord n T. It s easy to see that such a set of chords subdvdes the nteror of the polygon nto a collecton of trangles wth parwse dsont nterors (and hence the name trangulaton). It s not hard to prove (by nducton) that every trangulaton of an n-sded polygon conssts of n-3 chords and n- trangles. Trangulatons are of nterest for a number of reasons. Many geometrc algorthms operate by frst decomposng a complex polygonal shape nto rectangles. Then an algorthm can be appled trangle by trangle. Defne the dual graph of the trangulaton to be a graph whose vertces are the trangles, and n whch two vertces share a sde (are adacent) f the two trangles share a common chord. Observe that the dual graph s a tree. Hence algorthms for traversng trees can be used for traversng the trangles of a trangulaton. +. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 8 4

15 Mnmum-Weght Convex Polygon Trangulaton In general, gven a convex polygon, there are many possble trangulatons. In fact, the number s exponental n n, the number of sdes. Whch trangulaton s the ``best''? There are many crtera that are used dependng on the applcaton. One crteron s to magne that you must ``pay'' for the nk you use n drawng the trangulaton, and you want to mnmze the amount of nk you use. Ths suggests the followng nterestng problem. Mnmum-weght convex polygon trangulaton: Gven a convex polygon, determne the trangulaton that mnmzes the sum of the permeters of ts trangles. A trangulaton Another trangulaton The dual tree Gven three dstnct vertces v, we defne the weght of the assocated v, vk trangle by the weght functon w v, v, v ) = v v + v v + v v, ( k k k where v v denotes the length of the lne segment v v. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 9 Correspondence to Bnary Trees One explanaton behnd the smlarty of trangulatons and the chan matrx multplcaton algorthm s to observe that both are fundamentally related to bnary trees. In the case of the chan matrx multplcaton, the assocated bnary tree s the evaluaton tree for the multplcaton, where the leaves of the tree correspond to the matrces, and each node of the tree s assocated wth a product of a sequence of two or more matrces. To see that there s a smlar correspondence here, consder an (n + )-sded convex polygon P = v, v, v,..., v n, v n, and fx one sde of the polygon (say v v n ). Now consder a rooted bnary tree whose root node s the trangle contanng sde v v n, whose nternal nodes are the nodes of the dual tree, and whose leaves correspond to the remanng sdes of the polygon. Observe that parttonng the polygon nto trangles s equvalent to a bnary tree wth n leaves, and vce versa. Ths s llustrated n the fgure below. Note that every trangle s assocated wth an nternal node of the tree and every edge of the orgnal polygon, except for the dstngushed startng sde v v n, s assocated wth a leaf node of the tree. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 3 5

16 A Correspondence to Bnary Trees (cont.) v A v root v A root A 3 v v A v 3 A 4 v 9 v 4 v 8 A 9 A A A3 A4 A5 A6 A7 A8 A9 AA A 5 v 5 A 6 v 6 A 7 v 7 A 8 Once you see ths connecton. Then the followng two observatons follow easly. Observe that the assocated bnary tree has n leaves, and hence (by standard results on bnary trees) n- nternal nodes. Snce each nternal node other that the root has one edge enterng t, there are n- edges between the nternal nodes. Each nternal node corresponds to one trangle, and each edge between nternal nodes corresponds to one chord of the trangulaton. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 3 Dynamc Programmng Soluton Let us consder an (n+)-sded polygon P = v v, v,..., v n, v, n To derve a DP formulaton we need to defne a set of subproblems from whch we can derve the optmum soluton. For n, defne t[ ] to be the weght of the mnmum weght trangulaton for the subpolygon v, v..., v, assumng that the chord v v s already present n the trangulaton. (The reason that we start wth v rather than v s to keep the structure as smlar as possble to the chan-matrx multplcaton problem. We wll see ths below.) Observe that f we can compute ths quantty for all such and, then the weght of the mnmum weght trangulaton of the entre polygon wll be t[, n]. As a bass case, we defne the weght of the trval ``-sded polygon'' to be zero, mplyng that t[ ] (the lne segment ) to be. v v In general, to compute t[], consder the subpolygon, where <. One of the chords of ths polygon s the sde v. We may v, splt v,..., ths v subpolygon v by ntroducng a trangle whose base s ths chord, and whose thrd vertex s any vertex v k, where k.. Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 3 6

17 Dynamc Programmng Soluton (cont.) Ths subdvdes the polygon nto the subpolygons v, v..., vk and v k, vk +,..., v whose mnmum weght are already known to us as t[k] and t[k+,]. In addton we should consder the weght of newly added trangle v vkv. Thus, we have the followng recursve rule: t[ ] = mn f =, ( t[ k] + t[ k+, ] + w( v v v )) f <. k k Note that ths has exactly the same structure as the recursve defnton used n the chan-matrx multplcaton algorthms. The same Θ( n 3 ) algorthm can be appled wth only mnor changes. READ Ch. 5.3 n CLRS and agan all sldes about trangulatons (ths part was taken from the frst edton of the book (Ch. 6.4), you wll not fnd ths n the second edton). Homework : Problems 5.-(p.338), 5.-5(p.339), 5.3-3(p.349), 5.3-5(p.35), 5.4-(p.355), 5.4-5(p.356). Extra credt problem: 5-7(p.369). Advanced Algorthms, Feodor F. Dragan, Kent State Unversty 33 7

Kent State University CS 4/ Design and Analysis of Algorithms. Dept. of Math & Computer Science LECT-16. Dynamic Programming

Kent State University CS 4/ Design and Analysis of Algorithms. Dept. of Math & Computer Science LECT-16. Dynamic Programming CS 4/560 Desgn and Analyss of Algorthms Kent State Unversty Dept. of Math & Computer Scence LECT-6 Dynamc Programmng 2 Dynamc Programmng Dynamc Programmng, lke the dvde-and-conquer method, solves problems

More information

Complex Numbers. Now we also saw that if a and b were both positive then ab = a b. For a second let s forget that restriction and do the following.

Complex Numbers. Now we also saw that if a and b were both positive then ab = a b. For a second let s forget that restriction and do the following. Complex Numbers The last topc n ths secton s not really related to most of what we ve done n ths chapter, although t s somewhat related to the radcals secton as we wll see. We also won t need the materal

More information

Course Introduction. Algorithm 8/31/2017. COSC 320 Advanced Data Structures and Algorithms. COSC 320 Advanced Data Structures and Algorithms

Course Introduction. Algorithm 8/31/2017. COSC 320 Advanced Data Structures and Algorithms. COSC 320 Advanced Data Structures and Algorithms Course Introducton Course Topcs Exams, abs, Proects A quc loo at a few algorthms 1 Advanced Data Structures and Algorthms Descrpton: We are gong to dscuss algorthm complexty analyss, algorthm desgn technques

More information

(Feodor F. Dragan) Department of Computer Science Kent State University. Advanced Algorithms, Feodor F. Dragan, Kent State University 1

(Feodor F. Dragan) Department of Computer Science Kent State University. Advanced Algorithms, Feodor F. Dragan, Kent State University 1 $GYDQFH $OJRULWKPV (Feodor F. Dragan) Department of Computer Science Kent State University Advanced Algorithms, Feodor F. Dragan, Kent State University Textbook: Thomas Cormen, Charles Leisterson, Ronald

More information

GSLM Operations Research II Fall 13/14

GSLM Operations Research II Fall 13/14 GSLM 58 Operatons Research II Fall /4 6. Separable Programmng Consder a general NLP mn f(x) s.t. g j (x) b j j =. m. Defnton 6.. The NLP s a separable program f ts objectve functon and all constrants are

More information

6.854 Advanced Algorithms Petar Maymounkov Problem Set 11 (November 23, 2005) With: Benjamin Rossman, Oren Weimann, and Pouya Kheradpour

6.854 Advanced Algorithms Petar Maymounkov Problem Set 11 (November 23, 2005) With: Benjamin Rossman, Oren Weimann, and Pouya Kheradpour 6.854 Advanced Algorthms Petar Maymounkov Problem Set 11 (November 23, 2005) Wth: Benjamn Rossman, Oren Wemann, and Pouya Kheradpour Problem 1. We reduce vertex cover to MAX-SAT wth weghts, such that the

More information

CE 221 Data Structures and Algorithms

CE 221 Data Structures and Algorithms CE 1 ata Structures and Algorthms Chapter 4: Trees BST Text: Read Wess, 4.3 Izmr Unversty of Economcs 1 The Search Tree AT Bnary Search Trees An mportant applcaton of bnary trees s n searchng. Let us assume

More information

For instance, ; the five basic number-sets are increasingly more n A B & B A A = B (1)

For instance, ; the five basic number-sets are increasingly more n A B & B A A = B (1) Secton 1.2 Subsets and the Boolean operatons on sets If every element of the set A s an element of the set B, we say that A s a subset of B, or that A s contaned n B, or that B contans A, and we wrte A

More information

CMPS 10 Introduction to Computer Science Lecture Notes

CMPS 10 Introduction to Computer Science Lecture Notes CPS 0 Introducton to Computer Scence Lecture Notes Chapter : Algorthm Desgn How should we present algorthms? Natural languages lke Englsh, Spansh, or French whch are rch n nterpretaton and meanng are not

More information

Problem Set 3 Solutions

Problem Set 3 Solutions Introducton to Algorthms October 4, 2002 Massachusetts Insttute of Technology 6046J/18410J Professors Erk Demane and Shaf Goldwasser Handout 14 Problem Set 3 Solutons (Exercses were not to be turned n,

More information

Chapter 6 Programmng the fnte element method Inow turn to the man subject of ths book: The mplementaton of the fnte element algorthm n computer programs. In order to make my dscusson as straghtforward

More information

Mathematics 256 a course in differential equations for engineering students

Mathematics 256 a course in differential equations for engineering students Mathematcs 56 a course n dfferental equatons for engneerng students Chapter 5. More effcent methods of numercal soluton Euler s method s qute neffcent. Because the error s essentally proportonal to the

More information

The Greedy Method. Outline and Reading. Change Money Problem. Greedy Algorithms. Applications of the Greedy Strategy. The Greedy Method Technique

The Greedy Method. Outline and Reading. Change Money Problem. Greedy Algorithms. Applications of the Greedy Strategy. The Greedy Method Technique //00 :0 AM Outlne and Readng The Greedy Method The Greedy Method Technque (secton.) Fractonal Knapsack Problem (secton..) Task Schedulng (secton..) Mnmum Spannng Trees (secton.) Change Money Problem Greedy

More information

CSE 326: Data Structures Quicksort Comparison Sorting Bound

CSE 326: Data Structures Quicksort Comparison Sorting Bound CSE 326: Data Structures Qucksort Comparson Sortng Bound Steve Setz Wnter 2009 Qucksort Qucksort uses a dvde and conquer strategy, but does not requre the O(N) extra space that MergeSort does. Here s the

More information

5 The Primal-Dual Method

5 The Primal-Dual Method 5 The Prmal-Dual Method Orgnally desgned as a method for solvng lnear programs, where t reduces weghted optmzaton problems to smpler combnatoral ones, the prmal-dual method (PDM) has receved much attenton

More information

An Optimal Algorithm for Prufer Codes *

An Optimal Algorithm for Prufer Codes * J. Software Engneerng & Applcatons, 2009, 2: 111-115 do:10.4236/jsea.2009.22016 Publshed Onlne July 2009 (www.scrp.org/journal/jsea) An Optmal Algorthm for Prufer Codes * Xaodong Wang 1, 2, Le Wang 3,

More information

Parallelism for Nested Loops with Non-uniform and Flow Dependences

Parallelism for Nested Loops with Non-uniform and Flow Dependences Parallelsm for Nested Loops wth Non-unform and Flow Dependences Sam-Jn Jeong Dept. of Informaton & Communcaton Engneerng, Cheonan Unversty, 5, Anseo-dong, Cheonan, Chungnam, 330-80, Korea. seong@cheonan.ac.kr

More information

Assignment # 2. Farrukh Jabeen Algorithms 510 Assignment #2 Due Date: June 15, 2009.

Assignment # 2. Farrukh Jabeen Algorithms 510 Assignment #2 Due Date: June 15, 2009. Farrukh Jabeen Algorthms 51 Assgnment #2 Due Date: June 15, 29. Assgnment # 2 Chapter 3 Dscrete Fourer Transforms Implement the FFT for the DFT. Descrbed n sectons 3.1 and 3.2. Delverables: 1. Concse descrpton

More information

Programming in Fortran 90 : 2017/2018

Programming in Fortran 90 : 2017/2018 Programmng n Fortran 90 : 2017/2018 Programmng n Fortran 90 : 2017/2018 Exercse 1 : Evaluaton of functon dependng on nput Wrte a program who evaluate the functon f (x,y) for any two user specfed values

More information

CSCI 104 Sorting Algorithms. Mark Redekopp David Kempe

CSCI 104 Sorting Algorithms. Mark Redekopp David Kempe CSCI 104 Sortng Algorthms Mark Redekopp Davd Kempe Algorthm Effcency SORTING 2 Sortng If we have an unordered lst, sequental search becomes our only choce If we wll perform a lot of searches t may be benefcal

More information

News. Recap: While Loop Example. Reading. Recap: Do Loop Example. Recap: For Loop Example

News. Recap: While Loop Example. Reading. Recap: Do Loop Example. Recap: For Loop Example Unversty of Brtsh Columba CPSC, Intro to Computaton Jan-Apr Tamara Munzner News Assgnment correctons to ASCIIArtste.java posted defntely read WebCT bboards Arrays Lecture, Tue Feb based on sldes by Kurt

More information

Insertion Sort. Divide and Conquer Sorting. Divide and Conquer. Mergesort. Mergesort Example. Auxiliary Array

Insertion Sort. Divide and Conquer Sorting. Divide and Conquer. Mergesort. Mergesort Example. Auxiliary Array Inserton Sort Dvde and Conquer Sortng CSE 6 Data Structures Lecture 18 What f frst k elements of array are already sorted? 4, 7, 1, 5, 1, 16 We can shft the tal of the sorted elements lst down and then

More information

Dynamic Programming. Example - multi-stage graph. sink. source. Data Structures &Algorithms II

Dynamic Programming. Example - multi-stage graph. sink. source. Data Structures &Algorithms II Dynamc Programmng Example - mult-stage graph 1 source 9 7 3 2 2 3 4 5 7 11 4 11 8 2 2 1 6 7 8 4 6 3 5 6 5 9 10 11 2 4 5 12 snk Data Structures &Algorthms II A labeled, drected graph Vertces can be parttoned

More information

CSE 326: Data Structures Quicksort Comparison Sorting Bound

CSE 326: Data Structures Quicksort Comparison Sorting Bound CSE 326: Data Structures Qucksort Comparson Sortng Bound Bran Curless Sprng 2008 Announcements (5/14/08) Homework due at begnnng of class on Frday. Secton tomorrow: Graded homeworks returned More dscusson

More information

Sorting Review. Sorting. Comparison Sorting. CSE 680 Prof. Roger Crawfis. Assumptions

Sorting Review. Sorting. Comparison Sorting. CSE 680 Prof. Roger Crawfis. Assumptions Sortng Revew Introducton to Algorthms Qucksort CSE 680 Prof. Roger Crawfs Inserton Sort T(n) = Θ(n 2 ) In-place Merge Sort T(n) = Θ(n lg(n)) Not n-place Selecton Sort (from homework) T(n) = Θ(n 2 ) In-place

More information

Compiler Design. Spring Register Allocation. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Compiler Design. Spring Register Allocation. Sample Exercises and Solutions. Prof. Pedro C. Diniz Compler Desgn Sprng 2014 Regster Allocaton Sample Exercses and Solutons Prof. Pedro C. Dnz USC / Informaton Scences Insttute 4676 Admralty Way, Sute 1001 Marna del Rey, Calforna 90292 pedro@s.edu Regster

More information

Intro. Iterators. 1. Access

Intro. Iterators. 1. Access Intro Ths mornng I d lke to talk a lttle bt about s and s. We wll start out wth smlartes and dfferences, then we wll see how to draw them n envronment dagrams, and we wll fnsh wth some examples. Happy

More information

Load Balancing for Hex-Cell Interconnection Network

Load Balancing for Hex-Cell Interconnection Network Int. J. Communcatons, Network and System Scences,,, - Publshed Onlne Aprl n ScRes. http://www.scrp.org/journal/jcns http://dx.do.org/./jcns.. Load Balancng for Hex-Cell Interconnecton Network Saher Manaseer,

More information

Optimization Methods: Integer Programming Integer Linear Programming 1. Module 7 Lecture Notes 1. Integer Linear Programming

Optimization Methods: Integer Programming Integer Linear Programming 1. Module 7 Lecture Notes 1. Integer Linear Programming Optzaton Methods: Integer Prograng Integer Lnear Prograng Module Lecture Notes Integer Lnear Prograng Introducton In all the prevous lectures n lnear prograng dscussed so far, the desgn varables consdered

More information

Module Management Tool in Software Development Organizations

Module Management Tool in Software Development Organizations Journal of Computer Scence (5): 8-, 7 ISSN 59-66 7 Scence Publcatons Management Tool n Software Development Organzatons Ahmad A. Al-Rababah and Mohammad A. Al-Rababah Faculty of IT, Al-Ahlyyah Amman Unversty,

More information

An Application of the Dulmage-Mendelsohn Decomposition to Sparse Null Space Bases of Full Row Rank Matrices

An Application of the Dulmage-Mendelsohn Decomposition to Sparse Null Space Bases of Full Row Rank Matrices Internatonal Mathematcal Forum, Vol 7, 2012, no 52, 2549-2554 An Applcaton of the Dulmage-Mendelsohn Decomposton to Sparse Null Space Bases of Full Row Rank Matrces Mostafa Khorramzadeh Department of Mathematcal

More information

Today s Outline. Sorting: The Big Picture. Why Sort? Selection Sort: Idea. Insertion Sort: Idea. Sorting Chapter 7 in Weiss.

Today s Outline. Sorting: The Big Picture. Why Sort? Selection Sort: Idea. Insertion Sort: Idea. Sorting Chapter 7 in Weiss. Today s Outlne Sortng Chapter 7 n Wess CSE 26 Data Structures Ruth Anderson Announcements Wrtten Homework #6 due Frday 2/26 at the begnnng of lecture Proect Code due Mon March 1 by 11pm Today s Topcs:

More information

Sorting. Sorting. Why Sort? Consistent Ordering

Sorting. Sorting. Why Sort? Consistent Ordering Sortng CSE 6 Data Structures Unt 15 Readng: Sectons.1-. Bubble and Insert sort,.5 Heap sort, Secton..6 Radx sort, Secton.6 Mergesort, Secton. Qucksort, Secton.8 Lower bound Sortng Input an array A of data

More information

Sequential search. Building Java Programs Chapter 13. Sequential search. Sequential search

Sequential search. Building Java Programs Chapter 13. Sequential search. Sequential search Sequental search Buldng Java Programs Chapter 13 Searchng and Sortng sequental search: Locates a target value n an array/lst by examnng each element from start to fnsh. How many elements wll t need to

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Desgn and Analyss of Algorthms Heaps and Heapsort Reference: CLRS Chapter 6 Topcs: Heaps Heapsort Prorty queue Huo Hongwe Recap and overvew The story so far... Inserton sort runnng tme of Θ(n 2 ); sorts

More information

Priority queues and heaps Professors Clark F. Olson and Carol Zander

Priority queues and heaps Professors Clark F. Olson and Carol Zander Prorty queues and eaps Professors Clark F. Olson and Carol Zander Prorty queues A common abstract data type (ADT) n computer scence s te prorty queue. As you mgt expect from te name, eac tem n te prorty

More information

Hermite Splines in Lie Groups as Products of Geodesics

Hermite Splines in Lie Groups as Products of Geodesics Hermte Splnes n Le Groups as Products of Geodescs Ethan Eade Updated May 28, 2017 1 Introducton 1.1 Goal Ths document defnes a curve n the Le group G parametrzed by tme and by structural parameters n the

More information

Lecture 5: Multilayer Perceptrons

Lecture 5: Multilayer Perceptrons Lecture 5: Multlayer Perceptrons Roger Grosse 1 Introducton So far, we ve only talked about lnear models: lnear regresson and lnear bnary classfers. We noted that there are functons that can t be represented

More information

Solving two-person zero-sum game by Matlab

Solving two-person zero-sum game by Matlab Appled Mechancs and Materals Onlne: 2011-02-02 ISSN: 1662-7482, Vols. 50-51, pp 262-265 do:10.4028/www.scentfc.net/amm.50-51.262 2011 Trans Tech Publcatons, Swtzerland Solvng two-person zero-sum game by

More information

Brave New World Pseudocode Reference

Brave New World Pseudocode Reference Brave New World Pseudocode Reference Pseudocode s a way to descrbe how to accomplsh tasks usng basc steps lke those a computer mght perform. In ths week s lab, you'll see how a form of pseudocode can be

More information

R s s f. m y s. SPH3UW Unit 7.3 Spherical Concave Mirrors Page 1 of 12. Notes

R s s f. m y s. SPH3UW Unit 7.3 Spherical Concave Mirrors Page 1 of 12. Notes SPH3UW Unt 7.3 Sphercal Concave Mrrors Page 1 of 1 Notes Physcs Tool box Concave Mrror If the reflectng surface takes place on the nner surface of the sphercal shape so that the centre of the mrror bulges

More information

CS 534: Computer Vision Model Fitting

CS 534: Computer Vision Model Fitting CS 534: Computer Vson Model Fttng Sprng 004 Ahmed Elgammal Dept of Computer Scence CS 534 Model Fttng - 1 Outlnes Model fttng s mportant Least-squares fttng Maxmum lkelhood estmaton MAP estmaton Robust

More information

The Codesign Challenge

The Codesign Challenge ECE 4530 Codesgn Challenge Fall 2007 Hardware/Software Codesgn The Codesgn Challenge Objectves In the codesgn challenge, your task s to accelerate a gven software reference mplementaton as fast as possble.

More information

Machine Learning: Algorithms and Applications

Machine Learning: Algorithms and Applications 14/05/1 Machne Learnng: Algorthms and Applcatons Florano Zn Free Unversty of Bozen-Bolzano Faculty of Computer Scence Academc Year 011-01 Lecture 10: 14 May 01 Unsupervsed Learnng cont Sldes courtesy of

More information

On Some Entertaining Applications of the Concept of Set in Computer Science Course

On Some Entertaining Applications of the Concept of Set in Computer Science Course On Some Entertanng Applcatons of the Concept of Set n Computer Scence Course Krasmr Yordzhev *, Hrstna Kostadnova ** * Assocate Professor Krasmr Yordzhev, Ph.D., Faculty of Mathematcs and Natural Scences,

More information

Analysis of Continuous Beams in General

Analysis of Continuous Beams in General Analyss of Contnuous Beams n General Contnuous beams consdered here are prsmatc, rgdly connected to each beam segment and supported at varous ponts along the beam. onts are selected at ponts of support,

More information

Greedy Technique - Definition

Greedy Technique - Definition Greedy Technque Greedy Technque - Defnton The greedy method s a general algorthm desgn paradgm, bult on the follong elements: confguratons: dfferent choces, collectons, or values to fnd objectve functon:

More information

Harvard University CS 101 Fall 2005, Shimon Schocken. Assembler. Elements of Computing Systems 1 Assembler (Ch. 6)

Harvard University CS 101 Fall 2005, Shimon Schocken. Assembler. Elements of Computing Systems 1 Assembler (Ch. 6) Harvard Unversty CS 101 Fall 2005, Shmon Schocken Assembler Elements of Computng Systems 1 Assembler (Ch. 6) Why care about assemblers? Because Assemblers employ some nfty trcks Assemblers are the frst

More information

Machine Learning. Support Vector Machines. (contains material adapted from talks by Constantin F. Aliferis & Ioannis Tsamardinos, and Martin Law)

Machine Learning. Support Vector Machines. (contains material adapted from talks by Constantin F. Aliferis & Ioannis Tsamardinos, and Martin Law) Machne Learnng Support Vector Machnes (contans materal adapted from talks by Constantn F. Alfers & Ioanns Tsamardnos, and Martn Law) Bryan Pardo, Machne Learnng: EECS 349 Fall 2014 Support Vector Machnes

More information

Exercises (Part 4) Introduction to R UCLA/CCPR. John Fox, February 2005

Exercises (Part 4) Introduction to R UCLA/CCPR. John Fox, February 2005 Exercses (Part 4) Introducton to R UCLA/CCPR John Fox, February 2005 1. A challengng problem: Iterated weghted least squares (IWLS) s a standard method of fttng generalzed lnear models to data. As descrbed

More information

CS221: Algorithms and Data Structures. Priority Queues and Heaps. Alan J. Hu (Borrowing slides from Steve Wolfman)

CS221: Algorithms and Data Structures. Priority Queues and Heaps. Alan J. Hu (Borrowing slides from Steve Wolfman) CS: Algorthms and Data Structures Prorty Queues and Heaps Alan J. Hu (Borrowng sldes from Steve Wolfman) Learnng Goals After ths unt, you should be able to: Provde examples of approprate applcatons for

More information

Smoothing Spline ANOVA for variable screening

Smoothing Spline ANOVA for variable screening Smoothng Splne ANOVA for varable screenng a useful tool for metamodels tranng and mult-objectve optmzaton L. Rcco, E. Rgon, A. Turco Outlne RSM Introducton Possble couplng Test case MOO MOO wth Game Theory

More information

ON SOME ENTERTAINING APPLICATIONS OF THE CONCEPT OF SET IN COMPUTER SCIENCE COURSE

ON SOME ENTERTAINING APPLICATIONS OF THE CONCEPT OF SET IN COMPUTER SCIENCE COURSE Yordzhev K., Kostadnova H. Інформаційні технології в освіті ON SOME ENTERTAINING APPLICATIONS OF THE CONCEPT OF SET IN COMPUTER SCIENCE COURSE Yordzhev K., Kostadnova H. Some aspects of programmng educaton

More information

Notes on Organizing Java Code: Packages, Visibility, and Scope

Notes on Organizing Java Code: Packages, Visibility, and Scope Notes on Organzng Java Code: Packages, Vsblty, and Scope CS 112 Wayne Snyder Java programmng n large measure s a process of defnng enttes (.e., packages, classes, methods, or felds) by name and then usng

More information

NAG Fortran Library Chapter Introduction. G10 Smoothing in Statistics

NAG Fortran Library Chapter Introduction. G10 Smoothing in Statistics Introducton G10 NAG Fortran Lbrary Chapter Introducton G10 Smoothng n Statstcs Contents 1 Scope of the Chapter... 2 2 Background to the Problems... 2 2.1 Smoothng Methods... 2 2.2 Smoothng Splnes and Regresson

More information

11. APPROXIMATION ALGORITHMS

11. APPROXIMATION ALGORITHMS Copng wth NP-completeness 11. APPROXIMATION ALGORITHMS load balancng center selecton prcng method: vertex cover LP roundng: vertex cover generalzed load balancng knapsack problem Q. Suppose I need to solve

More information

Parallel matrix-vector multiplication

Parallel matrix-vector multiplication Appendx A Parallel matrx-vector multplcaton The reduced transton matrx of the three-dmensonal cage model for gel electrophoress, descrbed n secton 3.2, becomes excessvely large for polymer lengths more

More information

Parallel Numerics. 1 Preconditioning & Iterative Solvers (From 2016)

Parallel Numerics. 1 Preconditioning & Iterative Solvers (From 2016) Technsche Unverstät München WSe 6/7 Insttut für Informatk Prof. Dr. Thomas Huckle Dpl.-Math. Benjamn Uekermann Parallel Numercs Exercse : Prevous Exam Questons Precondtonng & Iteratve Solvers (From 6)

More information

LOOP ANALYSIS. The second systematic technique to determine all currents and voltages in a circuit

LOOP ANALYSIS. The second systematic technique to determine all currents and voltages in a circuit LOOP ANALYSS The second systematic technique to determine all currents and voltages in a circuit T S DUAL TO NODE ANALYSS - T FRST DETERMNES ALL CURRENTS N A CRCUT AND THEN T USES OHM S LAW TO COMPUTE

More information

UNIT 2 : INEQUALITIES AND CONVEX SETS

UNIT 2 : INEQUALITIES AND CONVEX SETS UNT 2 : NEQUALTES AND CONVEX SETS ' Structure 2. ntroducton Objectves, nequaltes and ther Graphs Convex Sets and ther Geometry Noton of Convex Sets Extreme Ponts of Convex Set Hyper Planes and Half Spaces

More information

Hierarchical clustering for gene expression data analysis

Hierarchical clustering for gene expression data analysis Herarchcal clusterng for gene expresson data analyss Gorgo Valentn e-mal: valentn@ds.unm.t Clusterng of Mcroarray Data. Clusterng of gene expresson profles (rows) => dscovery of co-regulated and functonally

More information

2x x l. Module 3: Element Properties Lecture 4: Lagrange and Serendipity Elements

2x x l. Module 3: Element Properties Lecture 4: Lagrange and Serendipity Elements Module 3: Element Propertes Lecture : Lagrange and Serendpty Elements 5 In last lecture note, the nterpolaton functons are derved on the bass of assumed polynomal from Pascal s trangle for the fled varable.

More information

Range images. Range image registration. Examples of sampling patterns. Range images and range surfaces

Range images. Range image registration. Examples of sampling patterns. Range images and range surfaces Range mages For many structured lght scanners, the range data forms a hghly regular pattern known as a range mage. he samplng pattern s determned by the specfc scanner. Range mage regstraton 1 Examples

More information

1 Dynamic Connectivity

1 Dynamic Connectivity 15-850: Advanced Algorthms CMU, Sprng 2017 Lecture #3: Dynamc Graph Connectvty algorthms 01/30/17 Lecturer: Anupam Gupta Scrbe: Hu Han Chn, Jacob Imola Dynamc graph algorthms s the study of standard graph

More information

A Binarization Algorithm specialized on Document Images and Photos

A Binarization Algorithm specialized on Document Images and Photos A Bnarzaton Algorthm specalzed on Document mages and Photos Ergna Kavalleratou Dept. of nformaton and Communcaton Systems Engneerng Unversty of the Aegean kavalleratou@aegean.gr Abstract n ths paper, a

More information

CS1100 Introduction to Programming

CS1100 Introduction to Programming Factoral (n) Recursve Program fact(n) = n*fact(n-) CS00 Introducton to Programmng Recurson and Sortng Madhu Mutyam Department of Computer Scence and Engneerng Indan Insttute of Technology Madras nt fact

More information

Lecture #15 Lecture Notes

Lecture #15 Lecture Notes Lecture #15 Lecture Notes The ocean water column s very much a 3-D spatal entt and we need to represent that structure n an economcal way to deal wth t n calculatons. We wll dscuss one way to do so, emprcal

More information

CS434a/541a: Pattern Recognition Prof. Olga Veksler. Lecture 15

CS434a/541a: Pattern Recognition Prof. Olga Veksler. Lecture 15 CS434a/541a: Pattern Recognton Prof. Olga Veksler Lecture 15 Today New Topc: Unsupervsed Learnng Supervsed vs. unsupervsed learnng Unsupervsed learnng Net Tme: parametrc unsupervsed learnng Today: nonparametrc

More information

Loop Transformations, Dependences, and Parallelization

Loop Transformations, Dependences, and Parallelization Loop Transformatons, Dependences, and Parallelzaton Announcements Mdterm s Frday from 3-4:15 n ths room Today Semester long project Data dependence recap Parallelsm and storage tradeoff Scalar expanson

More information

Performance Evaluation of Information Retrieval Systems

Performance Evaluation of Information Retrieval Systems Why System Evaluaton? Performance Evaluaton of Informaton Retreval Systems Many sldes n ths secton are adapted from Prof. Joydeep Ghosh (UT ECE) who n turn adapted them from Prof. Dk Lee (Unv. of Scence

More information

Reading. 14. Subdivision curves. Recommended:

Reading. 14. Subdivision curves. Recommended: eadng ecommended: Stollntz, Deose, and Salesn. Wavelets for Computer Graphcs: heory and Applcatons, 996, secton 6.-6., A.5. 4. Subdvson curves Note: there s an error n Stollntz, et al., secton A.5. Equaton

More information

Non-Split Restrained Dominating Set of an Interval Graph Using an Algorithm

Non-Split Restrained Dominating Set of an Interval Graph Using an Algorithm Internatonal Journal of Advancements n Research & Technology, Volume, Issue, July- ISS - on-splt Restraned Domnatng Set of an Interval Graph Usng an Algorthm ABSTRACT Dr.A.Sudhakaraah *, E. Gnana Deepka,

More information

SENSITIVITY ANALYSIS IN LINEAR PROGRAMMING USING A CALCULATOR

SENSITIVITY ANALYSIS IN LINEAR PROGRAMMING USING A CALCULATOR SENSITIVITY ANALYSIS IN LINEAR PROGRAMMING USING A CALCULATOR Judth Aronow Rchard Jarvnen Independent Consultant Dept of Math/Stat 559 Frost Wnona State Unversty Beaumont, TX 7776 Wnona, MN 55987 aronowju@hal.lamar.edu

More information

Intra-Parametric Analysis of a Fuzzy MOLP

Intra-Parametric Analysis of a Fuzzy MOLP Intra-Parametrc Analyss of a Fuzzy MOLP a MIAO-LING WANG a Department of Industral Engneerng and Management a Mnghsn Insttute of Technology and Hsnchu Tawan, ROC b HSIAO-FAN WANG b Insttute of Industral

More information

CHAPTER 10: ALGORITHM DESIGN TECHNIQUES

CHAPTER 10: ALGORITHM DESIGN TECHNIQUES CHAPTER 10: ALGORITHM DESIGN TECHNIQUES So far, we have been concerned wth the effcent mplementaton of algorthms. We have seen that when an algorthm s gven, the actual data structures need not be specfed.

More information

Line Clipping by Convex and Nonconvex Polyhedra in E 3

Line Clipping by Convex and Nonconvex Polyhedra in E 3 Lne Clppng by Convex and Nonconvex Polyhedra n E 3 Václav Skala 1 Department of Informatcs and Computer Scence Unversty of West Bohema Unverztní 22, Box 314, 306 14 Plzeò Czech Republc e-mal: skala@kv.zcu.cz

More information

Support Vector Machines

Support Vector Machines /9/207 MIST.6060 Busness Intellgence and Data Mnng What are Support Vector Machnes? Support Vector Machnes Support Vector Machnes (SVMs) are supervsed learnng technques that analyze data and recognze patterns.

More information

Assembler. Shimon Schocken. Spring Elements of Computing Systems 1 Assembler (Ch. 6) Compiler. abstract interface.

Assembler. Shimon Schocken. Spring Elements of Computing Systems 1 Assembler (Ch. 6) Compiler. abstract interface. IDC Herzlya Shmon Schocken Assembler Shmon Schocken Sprng 2005 Elements of Computng Systems 1 Assembler (Ch. 6) Where we are at: Human Thought Abstract desgn Chapters 9, 12 abstract nterface H.L. Language

More information

Fast Computation of Shortest Path for Visiting Segments in the Plane

Fast Computation of Shortest Path for Visiting Segments in the Plane Send Orders for Reprnts to reprnts@benthamscence.ae 4 The Open Cybernetcs & Systemcs Journal, 04, 8, 4-9 Open Access Fast Computaton of Shortest Path for Vstng Segments n the Plane Ljuan Wang,, Bo Jang

More information

AMath 483/583 Lecture 21 May 13, Notes: Notes: Jacobi iteration. Notes: Jacobi with OpenMP coarse grain

AMath 483/583 Lecture 21 May 13, Notes: Notes: Jacobi iteration. Notes: Jacobi with OpenMP coarse grain AMath 483/583 Lecture 21 May 13, 2011 Today: OpenMP and MPI versons of Jacob teraton Gauss-Sedel and SOR teratve methods Next week: More MPI Debuggng and totalvew GPU computng Read: Class notes and references

More information

Data Representation in Digital Design, a Single Conversion Equation and a Formal Languages Approach

Data Representation in Digital Design, a Single Conversion Equation and a Formal Languages Approach Data Representaton n Dgtal Desgn, a Sngle Converson Equaton and a Formal Languages Approach Hassan Farhat Unversty of Nebraska at Omaha Abstract- In the study of data representaton n dgtal desgn and computer

More information

Parallel Solutions of Indexed Recurrence Equations

Parallel Solutions of Indexed Recurrence Equations Parallel Solutons of Indexed Recurrence Equatons Yos Ben-Asher Dep of Math and CS Hafa Unversty 905 Hafa, Israel yos@mathcshafaacl Gad Haber IBM Scence and Technology 905 Hafa, Israel haber@hafascvnetbmcom

More information

U.C. Berkeley CS294: Beyond Worst-Case Analysis Handout 5 Luca Trevisan September 7, 2017

U.C. Berkeley CS294: Beyond Worst-Case Analysis Handout 5 Luca Trevisan September 7, 2017 U.C. Bereley CS294: Beyond Worst-Case Analyss Handout 5 Luca Trevsan September 7, 207 Scrbed by Haars Khan Last modfed 0/3/207 Lecture 5 In whch we study the SDP relaxaton of Max Cut n random graphs. Quc

More information

CHAPTER 2 DECOMPOSITION OF GRAPHS

CHAPTER 2 DECOMPOSITION OF GRAPHS CHAPTER DECOMPOSITION OF GRAPHS. INTRODUCTION A graph H s called a Supersubdvson of a graph G f H s obtaned from G by replacng every edge uv of G by a bpartte graph,m (m may vary for each edge by dentfyng

More information

Report on On-line Graph Coloring

Report on On-line Graph Coloring 2003 Fall Semester Comp 670K Onlne Algorthm Report on LO Yuet Me (00086365) cndylo@ust.hk Abstract Onlne algorthm deals wth data that has no future nformaton. Lots of examples demonstrate that onlne algorthm

More information

Efficient Distributed File System (EDFS)

Efficient Distributed File System (EDFS) Effcent Dstrbuted Fle System (EDFS) (Sem-Centralzed) Debessay(Debsh) Fesehaye, Rahul Malk & Klara Naherstedt Unversty of Illnos-Urbana Champagn Contents Problem Statement, Related Work, EDFS Desgn Rate

More information

Machine Learning. Topic 6: Clustering

Machine Learning. Topic 6: Clustering Machne Learnng Topc 6: lusterng lusterng Groupng data nto (hopefully useful) sets. Thngs on the left Thngs on the rght Applcatons of lusterng Hypothess Generaton lusters mght suggest natural groups. Hypothess

More information

An Approach in Coloring Semi-Regular Tilings on the Hyperbolic Plane

An Approach in Coloring Semi-Regular Tilings on the Hyperbolic Plane An Approach n Colorng Sem-Regular Tlngs on the Hyperbolc Plane Ma Louse Antonette N De Las Peñas, mlp@mathscmathadmueduph Glenn R Lago, glago@yahoocom Math Department, Ateneo de Manla Unversty, Loyola

More information

NUMERICAL SOLVING OPTIMAL CONTROL PROBLEMS BY THE METHOD OF VARIATIONS

NUMERICAL SOLVING OPTIMAL CONTROL PROBLEMS BY THE METHOD OF VARIATIONS ARPN Journal of Engneerng and Appled Scences 006-017 Asan Research Publshng Network (ARPN). All rghts reserved. NUMERICAL SOLVING OPTIMAL CONTROL PROBLEMS BY THE METHOD OF VARIATIONS Igor Grgoryev, Svetlana

More information

Problem Definitions and Evaluation Criteria for Computational Expensive Optimization

Problem Definitions and Evaluation Criteria for Computational Expensive Optimization Problem efntons and Evaluaton Crtera for Computatonal Expensve Optmzaton B. Lu 1, Q. Chen and Q. Zhang 3, J. J. Lang 4, P. N. Suganthan, B. Y. Qu 6 1 epartment of Computng, Glyndwr Unversty, UK Faclty

More information

Lecture 15: Memory Hierarchy Optimizations. I. Caches: A Quick Review II. Iteration Space & Loop Transformations III.

Lecture 15: Memory Hierarchy Optimizations. I. Caches: A Quick Review II. Iteration Space & Loop Transformations III. Lecture 15: Memory Herarchy Optmzatons I. Caches: A Quck Revew II. Iteraton Space & Loop Transformatons III. Types of Reuse ALSU 7.4.2-7.4.3, 11.2-11.5.1 15-745: Memory Herarchy Optmzatons Phllp B. Gbbons

More information

Topology Design using LS-TaSC Version 2 and LS-DYNA

Topology Design using LS-TaSC Version 2 and LS-DYNA Topology Desgn usng LS-TaSC Verson 2 and LS-DYNA Wllem Roux Lvermore Software Technology Corporaton, Lvermore, CA, USA Abstract Ths paper gves an overvew of LS-TaSC verson 2, a topology optmzaton tool

More information

ELEC 377 Operating Systems. Week 6 Class 3

ELEC 377 Operating Systems. Week 6 Class 3 ELEC 377 Operatng Systems Week 6 Class 3 Last Class Memory Management Memory Pagng Pagng Structure ELEC 377 Operatng Systems Today Pagng Szes Vrtual Memory Concept Demand Pagng ELEC 377 Operatng Systems

More information

Active Contours/Snakes

Active Contours/Snakes Actve Contours/Snakes Erkut Erdem Acknowledgement: The sldes are adapted from the sldes prepared by K. Grauman of Unversty of Texas at Austn Fttng: Edges vs. boundares Edges useful sgnal to ndcate occludng

More information

CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar

CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vdyanagar Faculty Name: Am D. Trved Class: SYBCA Subject: US03CBCA03 (Advanced Data & Fle Structure) *UNIT 1 (ARRAYS AND TREES) **INTRODUCTION TO ARRAYS If we want

More information

Simplification of 3D Meshes

Simplification of 3D Meshes Smplfcaton of 3D Meshes Addy Ngan /4/00 Outlne Motvaton Taxonomy of smplfcaton methods Hoppe et al, Mesh optmzaton Hoppe, Progressve meshes Smplfcaton of 3D Meshes 1 Motvaton Hgh detaled meshes becomng

More information

Tsinghua University at TAC 2009: Summarizing Multi-documents by Information Distance

Tsinghua University at TAC 2009: Summarizing Multi-documents by Information Distance Tsnghua Unversty at TAC 2009: Summarzng Mult-documents by Informaton Dstance Chong Long, Mnle Huang, Xaoyan Zhu State Key Laboratory of Intellgent Technology and Systems, Tsnghua Natonal Laboratory for

More information

Improving Low Density Parity Check Codes Over the Erasure Channel. The Nelder Mead Downhill Simplex Method. Scott Stransky

Improving Low Density Parity Check Codes Over the Erasure Channel. The Nelder Mead Downhill Simplex Method. Scott Stransky Improvng Low Densty Party Check Codes Over the Erasure Channel The Nelder Mead Downhll Smplex Method Scott Stransky Programmng n conjuncton wth: Bors Cukalovc 18.413 Fnal Project Sprng 2004 Page 1 Abstract

More information

Pass by Reference vs. Pass by Value

Pass by Reference vs. Pass by Value Pass by Reference vs. Pass by Value Most methods are passed arguments when they are called. An argument may be a constant or a varable. For example, n the expresson Math.sqrt(33) the constant 33 s passed

More information

An Entropy-Based Approach to Integrated Information Needs Assessment

An Entropy-Based Approach to Integrated Information Needs Assessment Dstrbuton Statement A: Approved for publc release; dstrbuton s unlmted. An Entropy-Based Approach to ntegrated nformaton Needs Assessment June 8, 2004 Wllam J. Farrell Lockheed Martn Advanced Technology

More information