当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

香港中文大学:《Design and Analysis of Algorithms》课程教学资源(辅导课件)tutorial 04

资源类别:文库,文档格式:PPTX,文档页数:29,文件大小:126.75KB,团购合买
点击下载完整版文档(PPTX)

CSCI 3160 Design and Analysis of Algorithms Tutorial 4 Chengyu Lin

CSCI 3160 Design and Analysis of Algorithms Tutorial 4 Chengyu Lin

Outline More examples about 2-SAT More randomized algorithms -Verifying Matrix Multiplication String Equality Test 。Design Patterns

Outline • More examples about 2-SAT • More randomized algorithms – Verifying Matrix Multiplication – String Equality Test • Design Patterns

2-SAT .Given (X1V-X2)A(X2V-X3)A(X4 VX3)A(X5 VX1)A(X4V-X5) .(X1,X2,X3,X4,Xs)=(T,T,T,T,T)is a satisfying assignment. Suppose you do not know about this solution You do not even know if there exists a solution for this formula How to decide if there is one using randomness?

2-SAT • Given (x1∨¬x2 )∧(x2∨¬x3 )∧(x4∨x3 )∧(x5∨x1 )∧(x4∨¬x5 ) • (x1 , x2 , x3 , x4 , x5 ) = (T, T, T, T, T) is a satisfying assignment. • Suppose you do not know about this solution • You do not even know if there exists a solution for this formula • How to decide if there is one using randomness?

2-SAT (X1V-X2)(X2V-X3)(X4VX3)(X5VX)(X4V-X5) 0 Start with a random assignment, -say (X1,X2,X3,Xa,Xs)=(F,T,F,F,T) Number of xis that agrees with the solution(i.e.number of i such thatx;=T) 0 2 3 5

2-SAT • (x1∨¬x2 )∧(x2∨¬x3 )∧(x4∨x3 )∧(x5∨x1 )∧(x4∨¬x5 ) • Start with a random assignment, – say (x1 , x2 , x3 , x4 , x5 ) = (F, T, F, F, T) 0 1 2 3 4 5 Number of xi s that agrees with the solution (i.e. number of i such that xi = T)

2-SAT (X1V-X2)^(X2V-X3)^(X4VX3)A(x5VX1)A(X4V-X5) clauses X1 X2 X3 Xa X5 current F T F F T Find an unsatisfied clause:(X4VX3) flip one of the value of x3 and x4 randomly If we flip x3,then we jump from 2 to 3 If we flip x4,then we jump from 2 to 3

2-SAT • (x1∨¬x2 )∧(x2∨¬x3 )∧(x4∨x3 )∧(x5∨x1 )∧(x4∨¬x5 ) • Find an unsatisfied clause: (x4∨x3 ) • flip one of the value of x3 and x4 randomly – If we flip x3 , then we jump from 2 to 3 – If we flip x4 , then we jump from 2 to 3 x1 x2 x3 x4 x5 current F T F F T clauses

2-SAT (X1V-X2)A(X2V-x3)A(X4VX3)(x5VX1)(X4V-X5) clauses X1 X2 X3 Xa X5 current F T F T Find an unsatisfied clause:(XV-X2) flip one of the value of xi and x2 randomly -If we flip x1,then we jump from 3 to 4 If we flip x2,then we jump from 3 to 2

2-SAT • (x1∨¬x2 )∧(x2∨¬x3 )∧(x4∨x3 )∧(x5∨x1 )∧(x4∨¬x5 ) • Find an unsatisfied clause: (x1∨¬x2 ) • flip one of the value of x1 and x2 randomly – If we flip x1 , then we jump from 3 to 4 – If we flip x2 , then we jump from 3 to 2 x1 x2 x3 x4 x5 current F T T F T clauses

2-SAT (X1V-X2)^(X2V-X3)^(X4VX3)A(x5VX1)A(X4V-X5) clauses X1 X2 X3 Xa X5 current F F T F T Find an unsatisfied clause:(X2 V-X3) flip one of the value of x2 and x3 randomly If we flip x2,then we jump from 2 to 3 If we flip x3,then we jump from 2 to 1

2-SAT • (x1∨¬x2 )∧(x2∨¬x3 )∧(x4∨x3 )∧(x5∨x1 )∧(x4∨¬x5 ) • Find an unsatisfied clause: (x2∨¬x3 ) • flip one of the value of x2 and x3 randomly – If we flip x2 , then we jump from 2 to 3 – If we flip x3 , then we jump from 2 to 1 x1 x2 x3 x4 x5 current F F T F T clauses

2-SAT (X1V-X2)A(X2V-x3)A(X4VX3)(x5VX1)(X4V-X5) clauses X1 X2 X3 Xa X5 current F T T F T Find an unsatisfied clause:(XV-X2) flip one of the value of xi and x2 randomly -If we flip x1,then we jump from 3 to 4 If we flip x2,then we jump from 3 to 2

2-SAT • (x1∨¬x2 )∧(x2∨¬x3 )∧(x4∨x3 )∧(x5∨x1 )∧(x4∨¬x5 ) • Find an unsatisfied clause: (x1∨¬x2 ) • flip one of the value of x1 and x2 randomly – If we flip x1 , then we jump from 3 to 4 – If we flip x2 , then we jump from 3 to 2 x1 x2 x3 x4 x5 current F T T F T clauses

2-SAT (X1V-X2)^(X2V-X3)^(X4Vx3)A(x5VX1)A(X4V-X5) clauses X1 X2 X3 Xa s current T T T F T Find an unsatisfied clause:(X4V-X5) flip one of the value of x4 and x5 randomly If we flip xa,then we jump from 4 to 5 If we flip xs,then we jump from 4 to 3

2-SAT • (x1∨¬x2 )∧(x2∨¬x3 )∧(x4∨x3 )∧(x5∨x1 )∧(x4∨¬x5 ) • Find an unsatisfied clause: (x4∨¬x5 ) • flip one of the value of x4 and x5 randomly – If we flip x4 , then we jump from 4 to 5 – If we flip x5 , then we jump from 4 to 3 x1 x2 x3 x4 x5 current T T T F T clauses

2-SAT (X1V-X2)A(X2V-x3)(X4VX3)(x5VX1)(X4V-X5) clauses X1 X2 X3 Xa X5 current T T T T T Find an unsatisfied clause:none We have a satisfying assignment!=

2-SAT • (x1∨¬x2 )∧(x2∨¬x3 )∧(x4∨x3 )∧(x5∨x1 )∧(x4∨¬x5 ) • Find an unsatisfied clause: none • We have a satisfying assignment! =) x1 x2 x3 x4 x5 current T T T T T clauses

点击下载完整版文档(PPTX)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共29页,试读已结束,阅读完整版请下载
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有