Try Magic Notes and save time.Try it free
Try Magic Notes and save timeCrush your year with the magic of personalized studying.Try it free
Question

# Suppose P is a formula in propositional logic containing n variables. Approximate the worst-case complexity of an algorithm that runs through all possible true/false values of the n variables to see if there is an assignment that makes P true.

Solution

Verified
Step 1
1 of 2

Given: $P$ is a propositional formula with $n$ variables.

Since there are at most two children to each vertex (true or false), a tree with $n$ vertices without children has a height of at least $\lceil \log_2n\rceil$.

For each of the $n$ variables, there are 2 options: true or false.

$\textbf{Multiplication principle: }$If one event can occur in $m$ ways AND a second event can occur in $n$ ways, then the number of ways that the two events can occur in sequence is then $m\cdot n$.

\begin{align*} \underbrace{2\cdot 2\cdot ...\cdot 2}_{n\text{ repetitions}}=2^n \end{align*}

Thus there are $2^n$ possible combinations of truth values for the $n$ variables and thus the tree representing the situation needs to have at least $2^n$ leaves.

The height of the tree is then at least $\lceil \log_2 2^n\rceil=\lceil n\rceil$ and thus the worst-case complexity of an algorithm that runs true all possible true/false values of hte $n$ variable is $\Theta(n)$.

## Recommended textbook solutions

#### Discrete Mathematics and Its Applications

7th EditionISBN: 9780073383095Kenneth Rosen
4,283 solutions

#### Discrete Mathematics and Its Applications

8th EditionISBN: 9781259676512Kenneth Rosen
4,397 solutions

#### Essentials of Discrete Mathematics

3rd EditionISBN: 9781284056242 (2 more)David J. Hunter
887 solutions

#### Discrete Mathematics with Applications

5th EditionISBN: 9781337694193Susanna S. Epp
2,641 solutions