hw6-sol - COT 5405 - Fall 2010 Homework 6(solution)...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

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

Unformatted text preview: COT 5405 - Fall 2010 Homework 6(solution) December 13, 2010 Grading Policy: Please contact TA Chunchun Zhao by email or in his o ce hours for any grading issues. Maximum score is 100 points. Each completed question worth 10 points. Problem 4 , 5 are graded for 25 points each. Partial credit is given if you dont answer a question completely. Please notify the TA if you nd anything wrong in this solution. Problem 1 Ex32.4-1: Compute the pre x function π for the pattern ababbabbabbabab- babb when the alphabet is ∑ = a,b . Solutions: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 P a b a b b a b b a b b a b a b b a b b π [ i ] 1 2 1 2 1 2 1 2 3 4 5 6 7 8 Ex32.4-5: Give a linear-time algorithm to determine if a text T is a cyclic rotation of another string T ´ . For example, arc and car are cyclic rotations of each other. Solutions: If T.strenglength 6 = T .strenglenth return false; else Let T 1 = TT ( concatenation of two strings T and T ; T 2 = T . This problem is equivalent to following string-macthing problem: Search for the pattern T 2 in string T 1 , which can be solved by KMP algorithm in linear time. 1 Problem 2 Ex34.4-3: Professor Jagger proposes to show that SAT ≤ P 3- CNF- SAT by using only the truth-table technique in the proof of Theorem 34.10, and not the other steps. That is, the professor proposes to take the boolean formula φ , form a truth table for its variables, derive from the truth table a formula in 3- DNF that is equivalent to ¬ φ , and then negate and apply DeMorgan's laws to produce a 3-CNF formula equivalent to φ . Show that this strategy does not yield a polynomial-time reduction. Solutions: Suppose φ has only one clause with n variables, forming the truth-table for this boolean formula will require 2 n rows. Thus the reduction is in time Ω(2 n ) . Ex34.4-7: Let 2-CNF-SAT be the set of satis able boolean formulas in CNF with exactly 2 literals per clause. Show that 2- CNF- SAT ∈ P . Make your algorithm as e cient as possible. (Hint: Observe that x W y is equivalent to ¬ x → y . Reduce 2-CNF-SAT to a problem on a directed graph that is e ciently solvable.) Solutions: Let I be an arbitrary instance of 2-Sat having n literals { x 1 ,x 2 ,...,x n } . Create a graph G = ( V,E ) represents I , where V = { x 1 ,x 2 ...,x n , ¬ x 1 , ¬ x 2 ,... ¬ x n } , E = { ( x i ,x j ) | either ( ¬ x i W x j ) or ( ¬ x j W x i ) in I } . Lemma: I is satis able if and only if there is no x i ∈ V such that there is a path from x i to ¬ x i and from ¬ x i to x i in G . Proof: 1) If there is a path x i to ¬ x i and a path ¬ x i to x i then I is unsatis able: If x is true, then by the transitivity of → , there must be one clause on that path from x i to ¬ x i is false ( T → F ) . I is unsatis able....
View Full Document

This note was uploaded on 01/15/2012 for the course COT 5405 taught by Professor Ungor during the Fall '08 term at University of Florida.

Page1 / 8

hw6-sol - COT 5405 - Fall 2010 Homework 6(solution)...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online