All Correct!

February 13, 2009 at 10:57 am Leave a comment

Write a function:
void printAllCorrect(char* expr);

which displays all possible ‘parenthesizing’s of expr which evaluate to Correct, where expr is of form:

Correct And Wrong Or Correct Xor Wrong

So, in this example we have 2 operands Correct and Wrong and there are 3 operators: And, Or, Xor. In general there can be n operands each of which shall be either Correct or Wrong, and m operators each of which shall be either of And, Or, Xor.

One possible solution is for the given example is:

(Correct And ((Wrong Or Correct) Xor Wrong))

What is the complexity of your solution?

Advertisements

Entry filed under: Puzzles.

Number of set bits Part II Ex’Squeeze’ me please

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Blog Stats

  • 4,036 hits

Recent Comments


%d bloggers like this: