15_q57f2ejv5yfe813 - , )S ¯ ¯ . ,S ." ¯ + NIL...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: , )S ¯ ¯ . ,S ." ¯ + NIL s- .Relax . π u ¯ ¯ ," ¯ .s- ¯ – (BF) .O(|V||E|) : ¯ – . 3 6 7 10 DFS All-Pairs Shortest Paths ¯ 2 5 7 9 12 (3) . .din(v)=dout(v) :V- v ¯ ¯ ¯ . .din(u)=dout(u) u≠v,w . ¯ ¯ ¯ ¯ . FW BFS (" 0/1 ) – ¯ " (2) (1) : (*) . ¯ 1 4 7 8 11 ¯ (" ) BF u.multinet.co.il min O(|V|4) : 3 .O(|V| log|V|) , .¯ ,¯ .π 2 ", " ¯" , ¯. min ¯ [(..(w*w)(w*w)..) ¯ ((…(w*w)*w)*w)..) ] |V| .(k-1 ) ,k " (2) .1 2 . n+1 π ¯ .π π .π . . v BF ,s h ¯ w*(u,v)=w(u,v)+h(u)-h(v) ¯ " ¯ ¯. .( All-Pairs Shortest Paths 6 . BF . ¯ log|v| ¯ ¯– . ¯ (1) : .O(|V|3) : ¯ ¯. - Johanson ¯ ¯ ' BF ¯ . |V|-1 ¯ ¯ ¯ ¯ w,v 2 2 ¯: ¯ - 1 (*) .w* . .O(|V| log|V|+|V||E|) : .v ¯ h(v)=δ(s,v) " w " h h:V-ℝ : 7 ! ,u≠s,t ¯: (3) .f(u,v)=-f(v,u) (2) .f(u,v)≤c(u,v) (1): ¯ X,Y (2) .f(A,B)=-f(B,A) (1) : ¯ .B ¯A ¯ : .cf(u,v)=c(u,v)-f(u,v) G – . ¯ ) Gf- t s. "f , ¯– ¯. :¯ .p Cf(p) .(Gf0 . ¯ , , ¯ .BFS ¯ . ' ¯. .(O(|E|) BFS ¯ O(|E||V|) ' ) O(|E|2|V|) . f (1) : , ". – MinCut-MaxFlow Gf (2) .(S,T) |f|=c(S,T) (3) .t s¯ .(|f|=)f(S,T)≤c(S,T) :(S,T) ¯f ¯: .|f|=f(S,T) (S,T) ¯f ¯: .T S BFS . . :¯ .( ¯ ) . BFS . ¯ BFS . ¯ " ¯ t ¯ ¯ ,(BFS " ) ¯ –' ¯ " " ¯ .DFS¯ . , ¯ , t¯. ¯ 2 ) ' ¯ O(|E||V|) ¯ ¯ ) O(|E||V| ) : ¯ .s . ¯ 1/0 / .(O(|V|) – ( ¯ ¯ ¯) O(|E|)' ¯ ¯ . .(0 ) 1 ¯ . " .(O(|E||V|1.5)) O(|E||V|) ¯ , ¯ .( ¯ –2 .O(|E||V|2/3) : ¯ .( ) –1 ! (2 1) (*) .O(|E||V|1/2) : ¯ .1 1 ¯ .2 ¯ ¯ .M 0 ¯ : .Y- A . π δ .( ¯ Γ(A)t- s A⊆X ¯ .|X|=|Y| ,E⊆XxY , A⊆ X ¯ ¯ .O(mn) )δ .T .O(n) " (|X|=|Y| .s,t∈V . ¯ ¯ ,¯ " G ¯) G=(V,E) – 8 ¯ ¯ .O(m+n) ,¯ – Hall G.| Γ(A)|≥|A| ¯" ,O(n) .(for j .( P :T[i] T P .(i-π(i) P x . " O(m3|Σ|) .O(m) – π ¯ . " " – KMP ) T[1…i] p ¯ τ(i) ¯ KMP .O(m+n) m-1 , ¯ T¯P ¯ n) n-min(m-1,1) (*) :' . ¯ P[1,…,j] – π[j] . ¯ - j ,T -i P =m=j (3) .π[j] - j (2) .1- j P[j+1]=T[i] (1) .(T[i+1] T ,j=0 ) .π[j] - j P[1..i]. π [P[1..i i – π(i) ). 2 4 ,2 P=ABABAC π(4) .O(m) i –τ(i) : KMP .FOR j ¯ KMP .T[1..i] .x P x –σ(x) : ¯ 9 ¯ (*) . ¯ ¯ (*) ¯ , (*) . " " ¯ (*) . ¯ ¯" / (*) . ¯ ¯ BFS 2 .( ¯ ) .uBFS ,su : d¯ 2 ¯ d , ¯. d¯ 2 ¯ Q , ¯: .( ¯ ) .( . ¯¯ : ¯ .d[u]=δ(s,u) ,u ¯: .i≤j+1 ¯ ¯j ¯ ,d BFS¯, ¯ (*) .¯ ¯ ¯ ¯¯ .( ¯ 2 BFS ¯) " ¯ : ( ¯ v2¯ ¯ v1 , ¯) .( V- S- " (u,v) ) δ(s,v) <= δ(s,u)+1 : (u,v) ¯: DFS 3 u,v 2 (2) . ¯ ¯ ,DFS -¯ ¯ (1) : ¯ (3) . π ¯ " .¯ DFS ? ¯ ¯ V1,…Vn – (DAG) ¯ (4) . " ? , (5) .( f V1) f(·) ¯ DFS , ¯ .i<j (Ui,Uj) ¯ ¯ – ¯ ¯ (6) . ¯ T ,GT DFS (3) .G (2) .L F G DFS (1) - ¯ .DAG (*) . " DFS ¯ (4) . L' ¯ T . G, .G G s- DFS , ¯ (*) . , 2- .[d(u),f(u)] u ¯¯ .V0 DFS V0→V1→…→Vn G– .( ¯ ) .DFS- V0 . DFS ¯ (*) . ' " ¯: .1 ¯ ¯2¯: π . ,DFS ,π , ¯ DFS- (*) .( ) (2) . (1) : . ← V (1) : U(U,V) ¯ ,¯ (*) . / 2 (3) . – 2 ¯ (*) . / ← (3) . ← (2) . (" ) 4 . ¯ (2) . (1) : ¯.¯ : .A¯2 , ¯– " .O(|E|log|E|)=O(|E|log|V|) : ¯ . " . (*) . ¯ (*) . " , : . " ¯ (*) ¯. ¯ . ¯C ¯ .C ¯ .O(|V|log|V| + |E|) – ' .( ¯) O(|E|log|v|) – :¯ .(O(|E|) O(||V|2)=|E| ) O(|V|2+|E|) .w* "T w " T w*(e)=f(w(e)) , f:ℛ⟶ℛ : .x1=y1, x2=y2… ¯ ,w " T1,T2 : (" ) 5 u .BFS –' . .( ) ¯s (3) .δ(s,v)≤δ(s,u)+w(u,v) (u,v)∈E : (2) . " " (1) : " ¯ '= ,1 ¯ (4) .δ(s,v)=δ(s,u)+w(u,v) v s- " v ,O(|V|log|V|+|E|log|E|) :¯ . ¯ " ADT , (*) .O(|V|+|V|*extract_min+|E|*update) – ¯ .O(|E|+|V|log|V|) .O(|E|+|V|) ¯ ¯ (O(|E|+|V|)- DFS) , (" )O(|E|+|V|) – :¯ .d[t]=min{d[t],d[v]+w(u,t)} " ¯ ¯ ¯ . . . , ,¯ : – ¯ 2 ¯ din(v)=dout(v)+1, din(w)+1=dout(w)¯ . ' ' 0/1 KMP Prim .O(|V|) – u.multinet.co.il cj ¯ aij ,ci1 , ¯ .( i1, …, ik , ¯ .ci1 ¯ ,ci1cik, …, cij- ¯" ,ci2: ,log(ai1,i2)+ log(ai2,i3)+…+log(ak-1,k)+log(aik,i1)>0 : log : .ai1,i2* ai2,i3*…* ak-1,k* aik,i1>1 : ¯ ¯ .c1, …, cn ( ¯ , ¯) ¯ .-log(ai1,i2)- log(ai2,i3)-…-log(ak-1,k)-log(aik,i1)<0 Bellman-Ford ¯ . .-log(aij) (ci, cj) .O(|V|*|E|)= O(n3) : .¯ ¯ ¯ ¯, ¯. ¯ .C: xi1, xi2, xik, xi1 ( ) : ¯ .( ¯ )G ¯ : xi ¯ s- Bellman-Ford , ( ). 0≤w(C)<0 δ(s, ¯ .¯ δ(s, xi) xi ¯ .i ¯ δ(s, xi)<∞ s¯ ¯ ,xi) ¯ δ(s, xi) ≤ δ(s, xj)+w(xj, xi) ¯ cij=w(xj, xi) ¯, xi-xj≤cij .δ(s, xi)- δ(s, xj)≤ cij .¯ . ¯: BF ,0 ¯ .0 ¯ : .(DFS ) G’.E'={(u, v)∈E| δ(s, v)= δ(s, u)+w(u, v)} : ¯ G' : .sG'C:v1, v2, …, vk, v1( ) .0 GG'- s: .0=w(C) ¯ .δ(s, v1)= δ(s, vk)+w(vk, v1),...,δ(s, v3)= δ(s, v2)+w(v2, v3) ,δ(s, v2)= δ(s, v1)+w(v1, v2) : .(vk, v1) ¯" .G'.G'.0 C:v1, v2, …, vk, v1 () .w(C)=0¯ 0<w(C) :¯" .δ(s, vk)≤ δ(s, vk-1)+w(vk-1, vk) ,... ,δ(s, v2) ≤ δ(s, v2)+w(v2, v3) ,δ(s, v1)< δ(s, v1)+w(v1, v2) : .( w.( ¯( ). d(u) ¯: ¯ . ." T ¯ , A¯. . ¯ .¯ .f(v)=δ(s,v) f ¯) F ,¯ ¯. ¯ .f(v)=f(u)+w(u,v) v¯ : . ¯ + ¯ ,Anxn={ai,j} :( , ¯, ) : c1, …, cn ¯ n : ) ci ) ¯ v. s¯ / (1) : . ¯ (1) : " (1) : " . , . ) (2) . . .( 0 – ) (1) : (3) .( s ¯ / DFS¯ (2) . –" " " ¯ ¯ : .( ¯) xj n xj : (i<j - ¯) xi ¯ 2 .n : ¯ 2 : " " (2) " ( . : ¯. ( ¯ ¯ ¯– )" (3) . " ¯: ." i¯ ¯ ¯" . :xj S ¯ ¯ ¯, x1,x2,…,xn ¯ ¯ ,1 . – 10 List a[1…n] [1…1] For j= 1 to n For i= 1 to j-1 If xi<xj then a[i]= a[j]+a[i]; S i S M(i-2,j-2) M(i-1,j-1) ¯ ¯T , ¯ ∈ ¯, . w , "¯w . , DFS v, v ( f . "¯w )v low(v) ¯ ) ( ¯ v v ¯. . ¯ (2) . ): ¯ low(w) ≥d[v] : ,v v- : . ,( ¯ v v v - ) low : ¯: v ¯ ,v ¯ –u (1) : ¯2¯: (u,v) : ¯ ¯" : 2 ¯v vu¯ . . ¯ ¯ ). If 2ai≤j then a[i,j]=a[i-1,j-2ai]+ a[i-1,j-ai]+ a[i-1,j] else if ai≤j then a[i,j]=a[i-1,j-ai]+ a[i-1,j] else a[i,j]=a[i-1,j] if(A [i-2]+A[i]>A[i-1]) M[i]←A[i-2]+A[i]; P[i]←<{i},i-2> else M[i]←A[i-1]; P[i]←<∅,i-1> ¯¯ .T- S ¯: . 50 ¯ ] ¯ .(T ij- ) T .O(mn):¯ .[M(i-50,j-1) ... .m 1≤a1<a2…<an<2n n : .xi∈{0,1,2} ¯ a1x1+a2x2+…+anxn=m ' 2 ¯ .ai 0…m(≤4n ) : . a1..ai ¯ ¯ =m ¯ 1 .(m=0 ¯ ¯) 1 ¯ ,0*a1O(mn) : ¯ .( ") .0 2*a1- 1*a1 ¯ j 1 T[i]=S[j] M(i,j) ¯ M M(i,j) ¯ A ¯ . ¯ ¯ ) . . n2 : .k ¯ . ¯ .S=max{Sn+,Sn-} ¯ ¯ ¯ ¯ . ¯ ¯ ¯ )¯ . : ¯ ¯M ¯P . " . ’ .n : : . ¯ ’ : .i 2 .P , ". .A n ¯ 2 ¯ A: (u,v) ¯, ¯ ¯ : ,¯ ¯ (3) . ¯ ¯ : . : . ' ¯ ¯ .T ¯ " ¯ ¯ . ¯, . ¯ ¯ .( ¯ " ¯) , . ¯ ¯ ¯ ¯ ′ ¯ . . . . ¯: , " T : ¯ . ¯ ¯ "T ¯. ¯ ,T " ¯ ¯ ¯. j=i-1; while j>0 and A[j]>A[i] j=j-1; If j=0 then M[i]=ai; P[i]=Nil; else M[i]=M[j]+ai; P[i]=j; ,T ¯ ¯ kn2 : ¯ ¯ ) ¯ .( ¯ Si- Si+ = ¯ + : ( . . ,( ) , ,k : ¯ ¯. ¯ , . ¯ ¯ ¯ " " 12 For j=0 to n { LCS[0,j] ∅ } For i=1 to m { LCS[i,0] ∅ for j=1 to n do If then LCS[i,j] LCS[i-1,j-1] ( ) Else LCS[i,j] max{LCS[i,j-1], LCS[i-1,j]} } ¯ ¯ , ¯ .xi / .Si+=S( ¯ . ¯ ¯ ,T for i=1 to n do C[i,i] 0 //0 for l=1 to n-1 do //i for i=1 to n-l do j i+i; C[i,j] ; for k=I to j-1 do t C[i,k]+C[k,j]+ if t<C[i,j] then C[i,j] , : .Si-=max{Si-1+,Si-1-} ,Si+=max{Si-1+xi, xi} : ¯ ¯ .pqr q×r p×q ¯. . ¯ = n p p ' ¯ ¯ . , " ¯" . ¯ . : . , +p . ¯ : ¯ t; [i,j] k ' " .f:V→R ,s , ¯ : , .(∞>d ) s¯ .s BFS ( ) .F f(s)≠0 ( ): ,¯ .f(u)+w(u,v) > f(v) (u,v) ¯ . ( ) .( s BFS .f(u)+w(u,v)=f(v) ¯ ( ) .F ,¯ .f(u)+w(u,v) < f(v) ¯ ,' : ¯ .T s.F , .s.O(|V|+|E|) : ¯ . ¯ .(f(v) δ(s,v) ¯) f(v) ¯,¯ ¯ Ford-Fulkerson .b(e)≤f(e)≤c(e) ¯ ¯ ¯ : .f-¯ . ¯ : ? ¯, .cg’(u,v)=c(u,v)-f(u,v) : ¯" : ¯. f: : ¯ .G’ Ford-Fulkerson .Cg’(v,u)=f(u,v)-b(u,v) : f’(u,v)≥f(u,v)+CG’(v,u)=f(u,v)+b(u,v)-f(u,v)=b(u,v) ,f’(u,v)≤f(u,v)+CG’(u,v)=f(u,v)+c(u,v)-f(u,v)=c(u,v) ¯ ¯" . 2 .O(|V||E| ) : ¯ . FF , ¯ .FF , . ¯ , ¯: 1¯ ¯ , . ¯ .1¯ . . 1¯ A⊆ X ¯. " : . |k|A .Γ(A) k A¯ ,¯ , ,¯ , .A .Hall ¯ . |(A|< |Γ(A| , ¯ .|k|A|<k|Γ(A) ¯ .Γ(A) ¯ k |k|Γ(A) . ¯ , ¯ .k k¯ ¯. ¯ .|(A|>|Γ(A| ¯ Γ(A)¯ An n: .|(A|<|Γ(A| .Γ(A) A- ". ¯ ¯ . . . . ¯ ,Nf=((V,Ef),cf,s,t) " ,f Ef ¯. . :1 : ¯ . : . 11 ,N=((V,E),c,s,t) :(residual network) ,u,v∈V ¯ cf(u,v)=c(u,v)-f(u,v) cf .( ¯ ) .Ef={(u,v):cf(u,v)>0} : " .s,t∈V G=(V,E) . . N ,k Nk : ¯ N.1 . ,Gk G¯ : : : .t- s- ¯ k c .t- s- ¯ ,N=(G,c,s,t) ...
View Full Document

Ask a homework question - tutors are online