最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

algorithm - Limiting the depth of Boolean expressions - Stack Overflow

matteradmin4PV0评论

I am given a Boolean expression of arbitrary depth, like (A or (B and (C or (~D and E) or F) or (G and H))). There can be any number of terms at each level.

I want to limit the depth of the expression (the maximum depth of nested parentheses + 1) to some constant like 4. If the depth exceeds that bound, then I want to generate an equivalent expression with depth that does not exceed the bound.

I know that I can convert to CNF or DNF, which would limit the depth to 2, but the size of the expression can blow up exponentially.

How can I take advantage of more available levels to limit the size of the resulting expression as much as possible?

Post a comment

comment list (0)

  1. No comments so far