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

Size: px
Start display at page:

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

Transcription

1 Dynamc Programmng Example - mult-stage graph 1 source snk Data Structures &Algorthms II

2 A labeled, drected graph Vertces can be parttoned nto k dsjont sets u, v E, u V, v V, 1 k k 1 V (source) V (snk) 1 1 Fnd the mn cost path from source to snk Data Structures &Algorthms II

3 Q: Wll dvde-and-conquer fnd the mnmum cost path? A: Probably not best left-half path best overall path best rght-half path Data Structures &Algorthms II

4 Best paths found ndependently may not form a path Best overall paths may be suboptmal at dfferent subproblem stages Dvde-and-Conquer requres subproblems to be ndependent! Data Structures &Algorthms II

5 Q: Wll the greedy method fnds the mnmum cost path? A: May not (f you are not Djkstra) Choose the shortest lnk frst Solve the problem stage-by-stage Cost may be very low mnmum cost at stage 1 Cost may be very hgh Data Structures &Algorthms II

6 A low cost edge may be followed by paths of a very hgh cost A hgh cost edge may be followed by paths of a very low cost Based on local nformaton (one stage at a tme) t mght not be possble to lookahead Pckng the remanng lowest cost edge may not generate a path Data Structures &Algorthms II

7 Q: Is there an applcaton? A: Yes, e.g., resource allocaton n unts of resources to be allocated to r projects N(,j) proft earned f j unts of resources are allocated to project goal s to maxmze the proft earned Data Structures &Algorthms II

8 V(project beng consdered, resources commtted) V(2,0) N(2,0) V(3,0) 3 projects 3 PCs N(1,0) V(2,1) N(2,1) V(3,1) V(1,0) N(1,1) N(1,2) V(2,2) N(2,2) V(3,2) V(4,3) N(1,3) V(2,3) N(2,3) V(3,3) Data Structures &Algorthms II

9 Surface Generaton n Tomography

10 p1 p2 m by n lattce Vertcal edge: an uprght trangle Horzontal edge: an nverted trangle Closed surfaces correspond to paths of length m+n Best path (surface) has the lowest cost

11 Q: What should we do? A: Enumerate all possbltes Q: How much s the cost of enumeraton? A: Hgh, for complete connecton between two adjacent stages n stages m vertces per stages O( m n ) Data Structures &Algorthms II

12

13 S D S D S S S S S S S D D D D D D D A lot of repettons: buld tables to remember partal solutons (reuse) S S S S S S S S D D D D D D D D A lot of alternatves: buld tables to remember optmal partal solutons (prncple of optmalty)

14 Q: Is there a more effcent method of enumeraton? A: Yes, dynamc programmng Underlyng prncples: Prncple of optmalty Early elmnaton of suboptmal subsolutons Recurson and reuse Construct solutons by reusng optmal subsolutons Early termnaton By feasblty or optmalty Data Structures &Algorthms II

15 Prncple of Optmalty Left half Rght half source snk (source to ) ( to snk) Data Structures &Algorthms II

16 The optmal soluton (f t go through node ) must contans the best left path from source to and best rght path from to snk Any other left paths from source to and any other rght paths from to snk need not be extended any further Data Structures &Algorthms II

17 Recurson and Reuse Identfy subproblems Record the optmal solutons of subproblems Buld larger and larger solutons source e 1 e 2 snk Any path that ncludes a porton of (source to ), the cost of that partcular porton s known

18 Feasblty Is a partal soluton stll feasble? Based on the current path alone Optmalty Is a partal soluton gong to be optmal? Based on comparson of the current path wth others

19 ( 1 6) Backward approach 9(mn( 4 9, 2 7)) ( 1 9) ( 1 2) ( 1 3) ( 1 4) ( 1 5) 9 ( 1 7) 7 11(mn( 2 9, 7 7, 11 2)) ( 110) ( 1 8) 15(mn( 9 6, 4 11)) 14(mn( 5 9, 3 11, 5 10)) ( 112) BCost(, j): 16(mn( 4 15, 2 14, 5 16)) (mn( 1 9, 11 3, 8 2)) ( 111) 16( 6 10) the cost of the optmal path from the source to vertex j at stage BCost(, j) mn { BCost(, l) c( j, l)} lv j, le source snk Data Structures &Algorthms II

20 ( 2 12) Forward approach 1 ( 6 12) ( 9 12) ( 10 12) ( 1112) 2 ( 7 12) ( 8 12) 7(mn( 6 4, 5 2)) 5(mn( 4 4, 3 2)) 7(mn( 5 2, 6 5)) ( 3 12) ( 4 12) ( 5 12) 7(mn( 4 7, 2 51, 7)) 9(mn( 2 7, 7 5)) ( 112) 4 Cost(, j): 18( 11 7) 16((mn( 9 7, 7 9, 3 18, 2 15)) 5 the cost of the optmal path from vertex j at stage to snk 15(mn( 11 5, 8 7)) Cost(, j) mn { c( j, l) Cost(, l)} lv j, le source Data Structures &Algorthms II snk

21 Intuton on DP Dynamc programmng sometmes can be confusng because t s bascally recurson but s slghtly more than recurson A general soluton pattern s dentfy stages and all possble alternatves n a stage recurson to generate all possble solutons need to combne and elmnate partal solutons usng prncple of optmalty

22 For mult-stage graph steps are defned by stages straght recurson generates brushy tree O(node^stage)

23 The mportant thng s to trm the tree by combnng and coalescng nodes by prncple of optmalty

24

25 Fancy Recursve Equatons Cost (node 1 at level 1) Mn (c(1,2)+cost(node 2 at level2), c(1,3)+cost(node 3 at level2), c(1,4)+cost(node 4 at level2),) Fancy equaton descrbes the recurson DP says that all such Cost functons should be reused!!

26 Remember the costs here Don t compute agan and agan

27 Important Characterstcs of Dynamc Programmng A sequence of decsons to be made Decsons are nter-dependent (Dvde-and- Conquer not applcable) Local nformaton not suffcent (Greedy not work) Data Structures &Algorthms II

28 Important Characterstcs of Dynamc Programmng (cont.) It examnes all solutons n an effcent manner It nvolves buldng solutons recursvely Prncple of optmalty s used to elmnate suboptmal solutons Table of some sort are usually used to store optmal partal solutons Some reuse of optmal partal solutons Mathematcally as recurson Data Structures &Algorthms II

29 Tme Complexty of DP DP == buldng tables of partal solutons 1. How many tables? 2. How many entres per table? 3. How much effort to fll n entres? 1*2*3 gves the complexty Data Structures &Algorthms II

30 Tme complexty of mult-stage graph One table s bult There are V entres n the table The cost of generatng an entry s proportonal to the ncdent edges O( V + E ): a sgnfcant savng over exponent runtme Data Structures &Algorthms II

31 0/1-Knapsack Input: a set of n objects a knapsack of capacty M Output: fll the knapsack (no partal ncluson) to maxmze the total proft earned Data Structures &Algorthms II

32 Greedy method can fal P ( 9, 7, 7), W ( 6, 5, 5), M 10 Greedy Optmal P 1 P 2 P 3 Dvde-and-conquer may not apply a a a a a 1 2 n n n subproblem (X?) subproblem (M-X) Data Structures &Algorthms II

33 How to buld solutons recursvely? One object at a tme How does prncple of optmalty apply? x x x x 1 2 n ( 1, xx x):( xx x) must be optmal for M W ( 0, y y y):( y y y) must be optmal for M 1 How to dentfy sub-optmal solutons? f two solutons: (1,,0,x,,x), and (0,,1,x,, x) are such that one acheves better proft wth less weght, then the other cannot be optmal Data Structures &Algorthms II

34 How to buld table? Proft Weght,,,, P=(1,2,5), W=(2,3,4),M=6 Boundng possble! (0,0) (Proft earned, Weght used) (1,2) (0,0) (3,5) (2,3) (1,2) (0,0) (8,9) (7,7) (6,6) (5,4) (3,5) (2,3) (1,2) (0,0) Data Structures &Algorthms II

35 How to wrte the recursve equaton? Knap(,X): current proft wth objects to n left to be processed wth a remanng capacty of X Intally, we have Knap(1,M) Knap( 1, M ) max{ Knap( 2, M ), Knap( 2, M W ) P} 1 1 Knap(, X ) max{ Knap( 1, X ), Knap( 1, X W ) P} Tme complexty An brushy tree for the table Constant tme to generate entres O( 2 n ) DP can help, but the complexty wll depend on actual problem nstance Data Structures &Algorthms II

36 Three Useful Trcks Feasblty If a branch s over capacty, don t expand t anymore Optmalty If a branch s worse than another branch (more capacty used wth smaller proft), don t expand t anymore Feasblty and optmalty are problem nstance specfc, cannot guarantee worst runtme n general Reuse Remember optmal partal solutons, don t regenerate over and over agan

37 Reuse Examples Weght = (3, 2, 3, 1, 4, 5), knapsack capacty = 10 Proft = (2, 3, 4, 1, 5, 1) Used capacty Max(2,4) Max(6,7) The complexty s O(n) wth reuse!

38 Relable Desgn Input: A system composed of several devces n seral Each devce (D) has a fxed relablty ratng (r) Multple copes of the same devce can be used n parallel to ncrease relablty Output: A system wth hghest relablty ratng subject to a cost constrant Data Structures &Algorthms II

39 D 1 D 1 D 1 D 2 D 2 D D D D n D D m max copes wth a 1n subject to of ( m 1n devces c m D relablty ratng ) C and at stage of m, 11, r 1 (1 : say,90% r ) n m Connected n parallel At least one should work Connected n seres All of them have to work Data Structures &Algorthms II

40 Greedy method may not be applcable Strategy to maxmze relablty: Buy more less relable unts (Costs may be hgh) Strategy to mnmze cost: Buy more less expensve unts (Relablty may not mprove sgnfcantly) Dvde-and-Conquer may fal D D D D D 1 2 n n n subproblem (X?) subproblem (C-X) Data Structures &Algorthms II

41 Comparson A knapsack of capacty C Objects of sze c and proft p Fll up the knapsack wth 0 or 1 copy of Maxmze proft Total expendture of C Stages of cost c and relablty r Construct a system wth 1 or more copes of Maxmze relablty u 1 C c n j1 c j Data Structures &Algorthms II

42 How to buld solutons recursvely? One stage and one devce at a tme How does prncple of optmalty apply? m m m m 1 2 n ( 1, xx x):( xx x) must be optmal for C c ( 2, y y y):( y y y) must be optmal for C 2 c ( u, y y y):( y y y) must be optmal for C u c How to dentfy sub-optmal solutons? f two solutons: (m1,,m,x,,x), and (n1,,n,x,, x) are such that one acheves hgher relablty wth a smaller cost, then the other cannot be optmal Data Structures &Algorthms II

43 How to buld table? r=(0.9,0.8,0.5), c=(30,15,20),c=105 (1,65) (relablty, cost) 1 ( ) ( ) ( ) 0. 8 (0.9,65) (0.99,95) 1 ( ) ( ) (0.72,65) (0.864,80) (0.893,95) (0.792,95) (0.95,110)(0.98,125) 1 ( ) 0. 5 (0.36,65) (0.63,105) (0.54,85) 1 ( ) ( 1 05) (0.432,80) (0.648,95) (0.756,110) (0.446,95) (0.781,135) (0.70,115)

44 How to wrte the recursve equaton? f ( X ): max ( m ) 1 j j subject to c m X, 1 m, 1 j 1 j j j f ( C) max { ( m ) f ( C c m )} n 1 m f ( X ) max{ ( m ) f ( X c m )} n 1 m n j j jn n n n1 n n 1 Tme complexty An brushy tree for the table Constant tme to generate entres O( 2 n ) Data Structures &Algorthms II

45 Chan Matrx Multplcaton Input: A sequence of n matrces Output Ther products

46 Even though not so obvous, greedy algorthms (e.g., keep ndvdual multplcatons small) do not always produce optmal solutons Furthermore, the costs can vary qute a bt dependng on the orderng A 135 B 589 (( AB) C) D ( AB)( CD) ( A( BC) D A(( BC) D) A( B( CD)) C D 334

47 Can dynamc programmng be used? Does the prncple of optmalty apply? Are there small problems? Can the subsolutons be reused and how?

48 Yes! There are many possble ways to apply DP, as long as do thngs n stages merge and reuse nodes based on prncple of optmalty We wll show some examples below

49 Based on the number of multplcatons performed (AB) (BC) (CD) (( AB ) C) ( AB )( CD) ( A ( BC)) (( BC ) D) ( B ( CD)) ( AB)( CD) ((( AB ) C) D) (( AB )( CD)) (( A ( BC)) D) ( A (( BC) D)) ( A ( B( CD))) (( AB)( CD))

50 An obvous DP algorthm need to multply all the matrces ndvdual steps wll be multplyng two adjacent matrces and reduce the number of matrces by one at each step, choose any two adjacent matrces to multply n n-1 steps, we wll be done reuse: (ABC) = ((AB) C), reuse results of (AB) prncple of optmalty: ((AB) C) and (A (BC)) produce the same results, keep one A perfectly legal DP algorthm!

51 The problem s that t s not a good DP algorthm wth n matrces frst multplcaton: n-1 possbltes second multplcaton:??? thrd multplcaton:??? even wth reuse and prncple of optmalty the numbers of ntermedate stages are large many multplcatons are repeated many tmes AB ((CD)(EF)) and ((AB)C)D(EF), (EF) s done more than once

52 Based on the number of matrces multpled together (the range of ndces) (A) (B) (C) (D) (AB) (BC) (CD) (ABC) (BCD) (ABCD)

53 Does the prncple of optmalty apply? Yes, whatever the last step n the chan multplcaton, the steps leadng to those two matrces must be optmal Are there small problems? Yes, multplcatons of two adjacent matrces Can the subsolutons be reused and how? Yes, 1 1,2,..., 1 1 1, n d d d m s n d d d m m m s k s k k s k s,..., 1,2 ) ( mn 1 1,,,

54 s s s s j D C B A ) , , 5 13 mn( ) , 89 5 mn( ) , 5 13 mn( m m m m m m m m m m m m m m m m m

55 Longest Increasng Subsequence Gven an array of n numbers [0..n-1], fnd a subset of numbers that are ncreasng [ ] [0 8 15] [ ] [2 3 7 ] [ ] <- longest one [ ] [ ]

56 Brute Force Method Every number can be ether n or not n n LIS Wth n numbers, there are 2 n subsequences Generate all, dscard those that are not ncreasng subsequences Complexty O(2 n )

57 DP Key Idea An partal LIS soln (head) must end at some ndex The same tal porton can be added to all these solns Only best soln s kept tal

58 0: not n the IS 1: n the IS

59 Include 1 Include 2 Include 3 Include 4 LIS k = best 0<=<k (LIS +1)

60 0, 8, 4, 1, 2, 2, 10, 6, 14, 1, 9, 5, 13 LIS k = best 0<=<k (LIS +1) 0 1 ( 0 ) 10 4 ( 0, 1, 2, 10 ) (0, 1, 2, 10) 8 2 ( 0, 8 ) 4 2 ( 0, 4 ) 1 2 ( 0, 1 ) 2 3 ( 0, 1, 2 ) 2 3 ( 0, 1, 2 ) 6 4 ( 0, 1, 2, 6 ) (0, 1, 2, 6) 14 5 ( 0, 1, 2, 10, 14 ) (0, 1, 2, 10, 14 (0,1,2,6, 14) (0, 1,2,6,14) 1 2 ( 0, 1 ) 9 5 ( 0, 1, 2, 6, 9 ) (0, 1, 2, 6, 9) 5 4 ( 0, 1, 2, 5) (0, 1, 2, 5) 13 6 ( 0, 1, 2, 6, 9, 13 ) (0, 1, 2, 6, 9

61 DP Key Idea (Reuse) How to buld table? LIS k = best 0<=<k (LIS +1) Fnal soluton? LIS = best 0<=k<n (LIS k ) Complexty One table n entres LIS k Most expensve entry O(n) O(n 2 ) More effcent (O(nlogn)) exsts

62 Sequence Algnment Gven two sequences a, b of length m, n Algn them to match Use n DNA matchng: a: AGCTTCGA b: GATCGA Deleton (nserton): 1 st A, 4 th or5 th T Change: 3 rd C->A AGCTTCGA GAT CGA AGCTTCGA GA TCGA

63 Constrants Lnear orderng If a matches wth b j, a k, k< must match only wth b l, l<j a k, k> must match only wth b l, l>j Deleton, nserton, and change all have assocated costs (doman dependent) Also called the longest common subsequence (LCS) problem (GTCGA) AGCTTCGA GA TCGA

64 Brute Force Method Agan, thnk about tree At each tree node, lookng at some a and some b j (ntally, a o, b o ) Match a and b j No change necessary Change a <-> b j Skp (delete) a, but keep b j Skp (delete) b j, but keep a Skp (delete) both a and b j Max fan out s 4, Max tree depth s m+n, bad

65 Prncple of Optmalty Smlar to LIS Head: some partal results (match, delete, nsert, change, etc.) up to a and b j Tal: (match, delete, nsert, change) results for a +1 and b j a tal b j

66 Reuse Buld a table of sze m by n to store the partal results (,j)th entry s results up to a b j How to fll the table? Fll them n dagonally C(,j) (W) = mn among R: C(-1,j-1) + (match, change, skp) a and b j G: C(,j-1) + skp b j j B: C(-1,j) + skp a Complexty: O(n 2 )

67 a a: AGCTTCGA b: GATCGA Match: 0 Delete (nsert): 1 Change: 1 b

68 a a: AGCTTCGA b: GATCGA Match: 0 Delete (nsert): 1 Change: 1? b

69 Polygon Trangulaton Gven: A convex polygon wth n sdes, a trangulaton s a set of chords of the polygon that dvde the polygon nto dsjont trangles There are n-2 trangles wth n-3 chords

70 Not all trangulatons are equally good Need a cost functon to evaluate the cost of a trangulaton The cost of a trangulaton s the total costs of ts component trangles The cost of a partcular trangle s the sum of some dstance measure (e.g., Eucldean) of all ts sdes,,, ),, ( k k j j k j v v v v v v v v v

71 Agan, dvde-and-conquer mght not work say, chose a chord to dvde the polygon nto two parts and perform trangulaton for both parts ndependently the sad chord wll be n the fnal trangulaton however, the optmal trangulaton may not nclude that partcular chord Greedy? the polygon of the smallest cost may not be n the fnal trangulaton Need to look at all possble combnatons

72 Intutvely, when we consder the frst step n trangulaton, say, usng v(0) and v(n-1) as base, the vertex can be v(1), v(2),, v(n-2) we do not know whch one s the best, should consder all possbltes Furthermore, f we pck, say v(j), then trangulaton of v(0) to v(j) and v(j) to v(n-1) must be optmal w.r.t each sub problems (prncple of optmalty) v v j v 0 v n1

73 Lke Matrx Multplcaton Multple two matrces Create one trangle Multply n-1 tmes Create n-2 trangles Randomly pck two matrces to multply Randomly pck a trangle to add Better to do t by gradually enlarge the chan Better to do t by gradually enlarge the trangle area Adjacency Adjacency

74 Prncple of Optmalty v v n1 v 0 v v1 2 v v n 2 v1 v 1 v 1 v n 2

75 Reuse f we need to trangulate an area nsde the orgnal polygon spanned by, say k, vertces f we already know the best way to trangulate an area spanned by k-1 vertces or less then we can take advantage of that!

76 That allows us to wrte the followng recurrence relaton let c(,j) be the cost of an optmal trangulaton of polygon <v(), v(+1), v(j)>, then j v v v j k c k c j c j or j j c j k j k 1 )),, ( ), ( ), ( mn( ), ( 1 0 ), ( k j

77 j j-=0 j-=1 C(,)=0 C(,+1)=0 C(,+2) C(k,j) C(,j) C(,k) = mn{ + + } j v v v j k c k c j c j or j j c j k j k 1 ),, ( ), ( ), ( mn( ), ( 1 0 ), ( startng endng

78 Optmal Bnary Search Tree Input: A set of n dentfers Output: An optmal bnary search tree that mnmzes the average search effort Data Structures &Algorthms II

79 else do n dentfers { a a,..., a } P( ): probablty that Q( ): probablty that search s for a symbol n E that a E a n P( ) Q( ) end f successful faled swtch 1 2 a 1 whle n s searched n successful: P( ) level( a ) n 1 faled: Q( ) ( level( E ) 1) 0

80 Convnce yourself that dvde-and-conquer and greedy methods are not sutable Dynamc Programmng Identfy small problems Progressvely buld larger problems Reuse optmal sub-solutons (table buldng) Data Structures &Algorthms II

81 How to buld soluton recursvely (reuse)? p( 1) Q( 0) Q( 1) p( 2) Q( 1) Q( 2) p( 3) Q( 2) Q( 3) a 1 a 2 a 3 p(2) Q(2) p(1) Q(0) p(3) Q(3) p(2) Q(1) ( p(1) Q(0) Q(1)) 2 ( p(2) Q(1) Q(2)) 2 ( p(2) Q(1) Q(2)) 2 ( p(3) Q(2) Q(3)) 2 a 2 a 1 a 3 a 2 a 1 a 2 a 2 a 3 Data Structures &Algorthms II

82 p(2) Q(2) ( p(1) Q(0) Q(1)) 2 a 2 a 1 p(2) ( p(1) Q(0) Q(1)) 2 ( p(3) Q(2) Q(3)) 2 p(1) Q(0) (( p(2) Q(1)) 2 ( p(3) Q(2) Q(3)) 3) a 1 p(3) Q(3) (( p(2) Q(2)) 2 ( p(1) Q(0) Q(1)) 3) a 3 a 2 a 2 a 1 a 3 a 2 a 1 a 3 Data Structures &Algorthms II

83 How does prncple of optmalty apply? p(2) Q(2) p(1) Q(0) p(3) Q(3) p(2) Q(1) ( p(1) Q(0) Q(1)) 2 ( p(2) Q(1) Q(2)) 2 ( p(2) Q(1) Q(2)) 2 ( p(3) Q(2) Q(3)) 3 a 2 a 1 a 3 a 2 a 1 a 2 a 2 a 3 Only one of the two confguratons should be kept! Data Structures &Algorthms II

84 Only one of the fve confguratons should be kept! a 1 a 3 a 2 a 2 a1 a 3 a 2 a 3 a 1 a 1 a 3 a3 a 1 a 2 a 2 Data Structures &Algorthms II

85 Lke Matrx Multplcaton Multple two matrces Pull one node up to root Multply n-1 tmes Create n-2 subtrees Randomly pck two matrces to multply Randomly pck a node up to be root Better to do t by gradually enlarge the chan Better to do t by gradually enlarge the subtree sze Adjacency Adjacency

86 a k R L E, a E a..., a E 0 1, 1, 2, k1, k1 L s optmal w.r.t. all bnary search trees wth the above elements C( L) p( ) level( a ) 1 k Q( ) ( level( E ) 1) 0k E, a E a..., a E k k1, k1, k2, n, n R s optmal w.r.t. all bnary search trees wth the above elements C( R) p( ) level( a ) kn Q( ) ( level( E ) 1) kn

87 C( combned ) p( k) C( L) C( R) p( ) Q( ) 1 k 0k p( ) Q( ) kn kn C( L) C( R) W( combned ) W( combned ) p( ) Q( ) p( k) p( ) Q( ) p( ) Q( ) 1 n 0n Recurrence relaton 1 k 0k kn kn C( 0, n) mn{ C( 0, k 1) C( k, n) W( 0, n)} 0kn C(, j) mn{ C(, k 1) C( k, j) W(, j)} k j Red: left got one deeper Blue: rght got one deeper Green: root Data Structures &Algorthms II

88 C(, j) mn{ C(, k 1) C( k, j) W(, j)} k j j C(,j) C(+1,j) C(+2,j) C(,j-1) C(j-1,j) j-=1 j-=0 C(,+2) C(,+1) C(,) = mn{ + + } Data Structures &Algorthms II

89 Table buldng j j-=n j-=2 j-=1 j-=0 order of computaton C(, ) 0 W(, ) P( k) Q( k) Q( ) 1 k k Data Structures &Algorthms II

90 How to compute W(,j)? Why not recursvely? E, a, E, a, E, a,..., a, E, a, E j1 j1 j j W(, j 1) W(, j) W(, j) p( j) Q( j) W(, j 1) Data Structures &Algorthms II

91 n 4 ( a, a, a, a ) ( do, f, read, whle) ( p, p, p, p ) ( 3, 311,, ) ( Q, Q, Q, Q, Q ) ( 2, 3111,,, ) j j-= j-= W(, j) p( j) Q( j) W(, j 1) =p(1)+Q(1)

92 C(0,4) mn{ C(0, k 1) C( k,4) W (0,4)} 0k4 mn{ C(0,0) C(1,4),(0 19) C(0,1) C(2,4),(8 8) C(0,2) C(3,4),(19 3) C(0,3) C(4,4),(25 0)} W (0,4),(16) C(, j) mn{ C(, k 1) C( k, j) W(, j)} k j j j-= j-= C( 1, 2) mn{ C( 1, k 1) C( k, 2) W( 1, 2)} 1k 2 C( 11, ) C( 2, 2) W( 1, 2) C( 0, 1) mn{ C( 0, k 1) C( k, 1) W( 0, 1)} 0k1 C( 0, 0) C( 11, ) W( 0, 1) Data Structures &Algorthms II

93 Tme Complexty - C(,j) j-=m, there are n-m+1 of them Each one takes mnmum of m quanttes n j ( n m 1) m O( n ) 0mn 3 C(0,n) C(n-1,n) C(n,n) j-=1 j-=0... C(2,3) C(.,.) 2 C(1,2) C(2,2) 1 C(0,1) C(1,1) 0 C(0,0) n Data Structures &Algorthms II

94 DP-based Graph Algorthms Graph = (vertces, edges) Edges Buld a long path wth many edges wth short paths wth fewer edges Stop when the path s longer than mn(e,n) Vertces Buld a subgraph wth wth many vertces wth smaller subgraphs wth fewer vertces Stop when all vertces are consdered Data Structures &Algorthms II

95 All Pars of Shortest Paths Input: a labeled graph G=(V,E) Output: the shortest path from very vertex to very other vertces Data Structures &Algorthms II

96 Soluton 1: Iteraton on the number of edges a drect path (length=1) paths of length=2 paths of length=mn(e,n) Soluton 2: Iteraton on the number of vertces a drect path (no ntervenng vertces) paths wth one ntervenng vertex paths wth (n-2) ntervenng vertces Data Structures &Algorthms II

97 Both solutons have ths recurrence relaton: C t (, j) mn{ C t1 (, j),mn{ C k, j 1 (, k) C t1 ( k, j)}} Gong through no other vertex V V 3 2 V 2 A nf 0 mn A Gong through one vertex A (0) (5) nf+6(3) (4) 11+nf (0) 2+nf 3+4 nf+0(7) 0+nf (6) (2) nf+2(0) Data Structures &Algorthms II

98 Tme Complexty How many tables? O(mn(e,n)) 2 How many entres per table? O( n ) How much effort to generate each entry? O(n) 3 4 O( n O(mn( e, n)) O( n ) OK solutons, but not great Try Floyd algorthm teratng on vertex s cardnal number Data Structures &Algorthms II

99 Travelng Salesperson Input: a drected labeled graph G=(V,E) Output: a tour of the mnmum cost a tour vsts all vertces a tour vst any vertex exactly once Data Structures &Algorthms II

100 Mult-stage graph Travelng salesman source snk source snk dffcult dffcult source snk source snk Cost(, j) mn { c( j, l) Cost(, l)} lv j, le canddate: n-1 vertces canddate: n-2 vertces 1 g(, S) mn{ c(, j) g( j, S { j})} 1 js Data Structures &Algorthms II

101 Dfference For travellng salesman source = snk Every vertex can possbly be at every stage O((n-1)!) complexty n-1 vertces!! source snk

102 Does the prncple of optmalty apply? Small problems wth reuse? source Only one need be kept! source

103 g(1, V {1}) mn{ c(1, k) 2kn g( k, V {1, k})} g(, S) mn{ c(, j) g( j, S { j})} js g(,s): the length of the shortest path startng at vertex, gong through all vertces n S, then back to the source Data Structures &Algorthms II

104 Data Structures &Algorthms II /5 9/13 12/9 20/8 10/8 15/ ) 25,20 25,15 mn(10 (1,{2,3,4}) 23 18) 15,9 mn(8 (4,{2,3}) 25 13) 18,12 mn(13 (3,{2,4}) 25 15) 20,10 mn(9 (2,{3,4}) 6) 15(9 (4,{3}) 5) 13(8 (4,{2}) 8) 20(12 (3,{4}) 5) 18(13 (3,{2}) 8) 18(10 (2,{4}) 6) 15(9 (2,{3}) 8 ) (4, 6 ) (3, 5 ) (2, g g g g g g g g g g g g g

105 Tme Complexty : there are n-1 vertces to vst at each level S: there are n 2 2 n ( n 1) O( n 2 ) k n2 k0 n 2 k choces C 12 C 13 g(1,v-{1}) C 1n g(2,v-{1,2}) g(3,v-{1,3}) g(,s) g(n,v-{1,n}) C 23 C 32 C 34 C 3n g(2,v-{1,2,3}) g(4,v-{1,3,4}) g(n,v-{1,3,n})

106 World Seres Odds DP may be used to solve problems where prncple of optmalty s not applcable Input: two teams A and B play a maxmum of 7 games whchever team frst wns 4 wns the seres Output: P(,j): condtonal probablty(a wns the seres A needs more games and B need j more games) Data Structures &Algorthms II

107 Even though prncple of optmalty does not apply here, but the problem does possess recursve nature solutons can be constructed by reuse P(, j) 1 0, j 0 0 0, j 0 P(, j) ( p( 1, j) p(, j 1)) / 2, 0, j 0 P(,j): condtonal probablty(a wns the seres A needs more games and B need j more games) Data Structures &Algorthms II

108 j P(, j) ( p( 1, j) p(, j 1)) / 2, 0, j /1613/16 21/32 1/2 j /8 3/4 11/16 1/2 11/32 1/2 5/16 3/16 (-1,j) (,j) /2 1/4 1/8 1/ (,j-1) Data Structures &Algorthms II

109 Brute force method A wns p(4,3) p(4,4) B wns A wns p(3,4) B wns A wns B wns +j=8 +j=7 p(3,3) p(4,2) p(2,4) p(3,3) +j=6 A wns B wns p(2,3) p(3,2) p(3,2) p(4,1) p(1,4) p(2,3) p(2,3) p(3,2) n O( 2 ) for brute force vs. O( n ) 2 for DP Data Structures &Algorthms II

110 Lessons Learned Basc prncples (Mult-stage graphs, 0/1-knapsack, Relable desgn) Brute force Reuse, Feasblty, Optmalty Table buldng (recurson) Beng Smart (Matrx multplcaton, polygon trangulaton) There are dfferent tables and dfferent recursons Beng flexble (World seres odds) Reuse regardless of optmalty constrant (more later) Nothng really matter much (Travelng Salesperson) There are hard problems n the unverse

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

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

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

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

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

Dijkstra s Single Source Algorithm. All-Pairs Shortest Paths. Dynamic Programming Solution. Performance. Decision Sequence.

Dijkstra s Single Source Algorithm. All-Pairs Shortest Paths. Dynamic Programming Solution. Performance. Decision Sequence. All-Pars Shortest Paths Gven an n-vertex drected weghted graph, fnd a shortest path from vertex to vertex for each of the n vertex pars (,). Dstra s Sngle Source Algorthm Use Dstra s algorthm n tmes, once

More information

Dijkstra s Single Source Algorithm. All-Pairs Shortest Paths. Dynamic Programming Solution. Performance

Dijkstra s Single Source Algorithm. All-Pairs Shortest Paths. Dynamic Programming Solution. Performance All-Pars Shortest Paths Gven an n-vertex drected weghted graph, fnd a shortest path from vertex to vertex for each of the n vertex pars (,). Dkstra s Sngle Source Algorthm Use Dkstra s algorthm n tmes,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

$OJRULWKPV. (Feodor F. Dragan) Department of Computer Science Kent State University $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,

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

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

Support Vector Machines

Support Vector Machines Support Vector Machnes Decson surface s a hyperplane (lne n 2D) n feature space (smlar to the Perceptron) Arguably, the most mportant recent dscovery n machne learnng In a nutshell: map the data to a predetermned

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

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

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

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

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

Conditional Speculative Decimal Addition*

Conditional Speculative Decimal Addition* Condtonal Speculatve Decmal Addton Alvaro Vazquez and Elsardo Antelo Dep. of Electronc and Computer Engneerng Unv. of Santago de Compostela, Span Ths work was supported n part by Xunta de Galca under grant

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

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

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

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

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

EECS 730 Introduction to Bioinformatics Sequence Alignment. Luke Huan Electrical Engineering and Computer Science

EECS 730 Introduction to Bioinformatics Sequence Alignment. Luke Huan Electrical Engineering and Computer Science EECS 730 Introducton to Bonformatcs Sequence Algnment Luke Huan Electrcal Engneerng and Computer Scence http://people.eecs.ku.edu/~huan/ HMM Π s a set of states Transton Probabltes a kl Pr( l 1 k Probablty

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

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

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

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

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

Outline. Self-Organizing Maps (SOM) US Hebbian Learning, Cntd. The learning rule is Hebbian like:

Outline. Self-Organizing Maps (SOM) US Hebbian Learning, Cntd. The learning rule is Hebbian like: Self-Organzng Maps (SOM) Turgay İBRİKÇİ, PhD. Outlne Introducton Structures of SOM SOM Archtecture Neghborhoods SOM Algorthm Examples Summary 1 2 Unsupervsed Hebban Learnng US Hebban Learnng, Cntd 3 A

More information

All-Pairs Shortest Paths. Approximate All-Pairs shortest paths Approximate distance oracles Spanners and Emulators. Uri Zwick Tel Aviv University

All-Pairs Shortest Paths. Approximate All-Pairs shortest paths Approximate distance oracles Spanners and Emulators. Uri Zwick Tel Aviv University Approxmate All-Pars shortest paths Approxmate dstance oracles Spanners and Emulators Ur Zwck Tel Avv Unversty Summer School on Shortest Paths (PATH05 DIKU, Unversty of Copenhagen All-Pars Shortest Paths

More information

CHAPTER 2 PROPOSED IMPROVED PARTICLE SWARM OPTIMIZATION

CHAPTER 2 PROPOSED IMPROVED PARTICLE SWARM OPTIMIZATION 24 CHAPTER 2 PROPOSED IMPROVED PARTICLE SWARM OPTIMIZATION The present chapter proposes an IPSO approach for multprocessor task schedulng problem wth two classfcatons, namely, statc ndependent tasks and

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

A mathematical programming approach to the analysis, design and scheduling of offshore oilfields

A mathematical programming approach to the analysis, design and scheduling of offshore oilfields 17 th European Symposum on Computer Aded Process Engneerng ESCAPE17 V. Plesu and P.S. Agach (Edtors) 2007 Elsever B.V. All rghts reserved. 1 A mathematcal programmng approach to the analyss, desgn and

More information

Proper Choice of Data Used for the Estimation of Datum Transformation Parameters

Proper Choice of Data Used for the Estimation of Datum Transformation Parameters Proper Choce of Data Used for the Estmaton of Datum Transformaton Parameters Hakan S. KUTOGLU, Turkey Key words: Coordnate systems; transformaton; estmaton, relablty. SUMMARY Advances n technologes and

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

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

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

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

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

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

Simulation Based Analysis of FAST TCP using OMNET++

Simulation Based Analysis of FAST TCP using OMNET++ Smulaton Based Analyss of FAST TCP usng OMNET++ Umar ul Hassan 04030038@lums.edu.pk Md Term Report CS678 Topcs n Internet Research Sprng, 2006 Introducton Internet traffc s doublng roughly every 3 months

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

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

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

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

Biostatistics 615/815

Biostatistics 615/815 The E-M Algorthm Bostatstcs 615/815 Lecture 17 Last Lecture: The Smplex Method General method for optmzaton Makes few assumptons about functon Crawls towards mnmum Some recommendatons Multple startng ponts

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 FORM ONE SCHEME OF WORK 2004

MATHEMATICS FORM ONE SCHEME OF WORK 2004 MATHEMATICS FORM ONE SCHEME OF WORK 2004 WEEK TOPICS/SUBTOPICS LEARNING OBJECTIVES LEARNING OUTCOMES VALUES CREATIVE & CRITICAL THINKING 1 WHOLE NUMBER Students wll be able to: GENERICS 1 1.1 Concept of

More information

Circuit Analysis I (ENGR 2405) Chapter 3 Method of Analysis Nodal(KCL) and Mesh(KVL)

Circuit Analysis I (ENGR 2405) Chapter 3 Method of Analysis Nodal(KCL) and Mesh(KVL) Crcut Analyss I (ENG 405) Chapter Method of Analyss Nodal(KCL) and Mesh(KVL) Nodal Analyss If nstead of focusng on the oltages of the crcut elements, one looks at the oltages at the nodes of the crcut,

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

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

Cache Performance 3/28/17. Agenda. Cache Abstraction and Metrics. Direct-Mapped Cache: Placement and Access

Cache Performance 3/28/17. Agenda. Cache Abstraction and Metrics. Direct-Mapped Cache: Placement and Access Agenda Cache Performance Samra Khan March 28, 217 Revew from last lecture Cache access Assocatvty Replacement Cache Performance Cache Abstracton and Metrcs Address Tag Store (s the address n the cache?

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

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

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

Variant Multi Objective Tsp Model

Variant Multi Objective Tsp Model Volume Issue 06 Pages-656-670 June-06 ISSN e): 395-70 Varant Mult Objectve Tsp Model K.Vjaya Kumar, P.Madhu Mohan Reddy, C. Suresh Babu, M.Sundara Murthy Department of Mathematcs, Sr Venkateswara Unversty,

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

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

Computer Animation and Visualisation. Lecture 4. Rigging / Skinning

Computer Animation and Visualisation. Lecture 4. Rigging / Skinning Computer Anmaton and Vsualsaton Lecture 4. Rggng / Sknnng Taku Komura Overvew Sknnng / Rggng Background knowledge Lnear Blendng How to decde weghts? Example-based Method Anatomcal models Sknnng Assume

More information

Private Information Retrieval (PIR)

Private Information Retrieval (PIR) 2 Levente Buttyán Problem formulaton Alce wants to obtan nformaton from a database, but she does not want the database to learn whch nformaton she wanted e.g., Alce s an nvestor queryng a stock-market

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

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

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

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

Meta-heuristics for Multidimensional Knapsack Problems

Meta-heuristics for Multidimensional Knapsack Problems 2012 4th Internatonal Conference on Computer Research and Development IPCSIT vol.39 (2012) (2012) IACSIT Press, Sngapore Meta-heurstcs for Multdmensonal Knapsack Problems Zhbao Man + Computer Scence Department,

More information

Sorting: The Big Picture. The steps of QuickSort. QuickSort Example. QuickSort Example. QuickSort Example. Recursive Quicksort

Sorting: The Big Picture. The steps of QuickSort. QuickSort Example. QuickSort Example. QuickSort Example. Recursive Quicksort Sortng: The Bg Pcture Gven n comparable elements n an array, sort them n an ncreasng (or decreasng) order. Smple algorthms: O(n ) Inserton sort Selecton sort Bubble sort Shell sort Fancer algorthms: O(n

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

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

Concurrent Apriori Data Mining Algorithms

Concurrent Apriori Data Mining Algorithms Concurrent Apror Data Mnng Algorthms Vassl Halatchev Department of Electrcal Engneerng and Computer Scence York Unversty, Toronto October 8, 2015 Outlne Why t s mportant Introducton to Assocaton Rule Mnng

More information

Very simple computational domains can be discretized using boundary-fitted structured meshes (also called grids)

Very simple computational domains can be discretized using boundary-fitted structured meshes (also called grids) Structured meshes Very smple computatonal domans can be dscretzed usng boundary-ftted structured meshes (also called grds) The grd lnes of a Cartesan mesh are parallel to one another Structured meshes

More information

3. CR parameters and Multi-Objective Fitness Function

3. CR parameters and Multi-Objective Fitness Function 3 CR parameters and Mult-objectve Ftness Functon 41 3. CR parameters and Mult-Objectve Ftness Functon 3.1. Introducton Cogntve rados dynamcally confgure the wreless communcaton system, whch takes beneft

More information

Real-Time Guarantees. Traffic Characteristics. Flow Control

Real-Time Guarantees. Traffic Characteristics. Flow Control Real-Tme Guarantees Requrements on RT communcaton protocols: delay (response s) small jtter small throughput hgh error detecton at recever (and sender) small error detecton latency no thrashng under peak

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

Array transposition in CUDA shared memory

Array transposition in CUDA shared memory Array transposton n CUDA shared memory Mke Gles February 19, 2014 Abstract Ths short note s nspred by some code wrtten by Jeremy Appleyard for the transposton of data through shared memory. I had some

More information

Efficient Load-Balanced IP Routing Scheme Based on Shortest Paths in Hose Model. Eiji Oki May 28, 2009 The University of Electro-Communications

Efficient Load-Balanced IP Routing Scheme Based on Shortest Paths in Hose Model. Eiji Oki May 28, 2009 The University of Electro-Communications Effcent Loa-Balance IP Routng Scheme Base on Shortest Paths n Hose Moel E Ok May 28, 2009 The Unversty of Electro-Communcatons Ok Lab. Semnar, May 28, 2009 1 Outlne Backgroun on IP routng IP routng strategy

More information

A Simple Methodology for Database Clustering. Hao Tang 12 Guangdong University of Technology, Guangdong, , China

A Simple Methodology for Database Clustering. Hao Tang 12 Guangdong University of Technology, Guangdong, , China for Database Clusterng Guangdong Unversty of Technology, Guangdong, 0503, Chna E-mal: 6085@qq.com Me Zhang Guangdong Unversty of Technology, Guangdong, 0503, Chna E-mal:64605455@qq.com Database clusterng

More information

Sorting and Algorithm Analysis

Sorting and Algorithm Analysis Unt 7 Sortng and Algorthm Analyss Computer Scence S-111 Harvard Unversty Davd G. Sullvan, Ph.D. Sortng an Array of Integers 0 1 2 n-2 n-1 arr 15 7 36 40 12 Ground rules: sort the values n ncreasng order

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

Needed Information to do Allocation

Needed Information to do Allocation Complexty n the Database Allocaton Desgn Must tae relatonshp between fragments nto account Cost of ntegrty enforcements Constrants on response-tme, storage, and processng capablty Needed Informaton to

More information

Graph-based Clustering

Graph-based Clustering Graphbased Clusterng Transform the data nto a graph representaton ertces are the data ponts to be clustered Edges are eghted based on smlarty beteen data ponts Graph parttonng Þ Each connected component

More information

Collision Detection. Overview. Efficient Collision Detection. Collision Detection with Rays: Example. C = nm + (n choose 2)

Collision Detection. Overview. Efficient Collision Detection. Collision Detection with Rays: Example. C = nm + (n choose 2) Overvew Collson detecton wth Rays Collson detecton usng BSP trees Herarchcal Collson Detecton OBB tree, k-dop tree algorthms Multple object CD system Collson Detecton Fundamental to graphcs, VR applcatons

More information

Control strategies for network efficiency and resilience with route choice

Control strategies for network efficiency and resilience with route choice Control strateges for networ effcency and reslence wth route choce Andy Chow Ru Sha Centre for Transport Studes Unversty College London, UK Centralsed strateges UK 1 Centralsed strateges Some effectve

More information

A Fast Content-Based Multimedia Retrieval Technique Using Compressed Data

A Fast Content-Based Multimedia Retrieval Technique Using Compressed Data A Fast Content-Based Multmeda Retreval Technque Usng Compressed Data Borko Furht and Pornvt Saksobhavvat NSF Multmeda Laboratory Florda Atlantc Unversty, Boca Raton, Florda 3343 ABSTRACT In ths paper,

More information

Optimizing Document Scoring for Query Retrieval

Optimizing Document Scoring for Query Retrieval Optmzng Document Scorng for Query Retreval Brent Ellwen baellwe@cs.stanford.edu Abstract The goal of ths project was to automate the process of tunng a document query engne. Specfcally, I used machne learnng

More information

Fitting & Matching. Lecture 4 Prof. Bregler. Slides from: S. Lazebnik, S. Seitz, M. Pollefeys, A. Effros.

Fitting & Matching. Lecture 4 Prof. Bregler. Slides from: S. Lazebnik, S. Seitz, M. Pollefeys, A. Effros. Fttng & Matchng Lecture 4 Prof. Bregler Sldes from: S. Lazebnk, S. Setz, M. Pollefeys, A. Effros. How do we buld panorama? We need to match (algn) mages Matchng wth Features Detect feature ponts n both

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