Note that there are some explanatory texts on larger screens.

plurals
  1. POParenthesizing a string so that expression takes a given value
    primarykey
    data
    text
    <p>The following problem is from the chapter on Dynamic Programming by Vazirani et. al.</p> <hr> <p>[6.6]Let us define a multiplication operation(×) on three symbols a; b; c according to the following table:</p> <p><img src="https://i.imgur.com/HcUWS.png" alt="Multiplication table"></p> <p>Therefore, a × a = b , a × b = b etc.</p> <p>Find an efficient algorithm that examines a string of these symbols, say bbbbac, and decides whether or not it is possible to parenthesize the string in such a way that the value of the resulting expression is a. For example, on input bbbbac your algorithm should return yes because ((b(bb))(ba))c = a.</p> <hr> <p>Here is my approach: Map it to the problem of counting the number of boolean parenthesizations as given <strong><a href="https://stackoverflow.com/questions/6701812/counting-boolean-parenthesizations-implementation">here</a></strong>. In that problem, you are given a boolean expression of the form</p> <p>T <em>or</em> F <em>and</em> T <em>xor</em> T</p> <p>and you need to find the number of ways of parenthesizing this so that it evaluates to true. </p> <p>We can think of <em>or</em> , <em>and</em> , <em>xor</em> as operators which follow certain rules (T <em>xor</em> F = T etc.) and act on operands taking values T or F. For our original problem, we can think of a,b,c as operands with multiplication(x) <em>as defined by the given table</em> as providing the rules. </p> <p>Does the above approach make sense or is there a simpler approach ? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload