CS 253 Homework # 3
Problem 1.
In propositional logic, elementary propositions may be combined
by five logical connectives:
P <--> Q : P if and only if Q
P --> Q : If P then Q (or P implies Q)
P & Q : P and Q
P v Q : P or Q
~ P : not P
The truth tables for these logical connectives are:
P Q | P <--> Q | P --> Q | P & Q | P v Q | ~ P
T T | T | T | T | T | F
T F | F | F | F | T | F
F T | F | T | F | T | T
F F | T | T | F | F | T
Logical expressions involving these connectives may combine
many connectives applied according to the following operation
hierarchy:
all ~ are applied first
next all & are applied
next all v are applied
next all --> are applied
finally all <--> are applied
Parentheses may be used to override this hierarchy.
A Logical expression which always evaluates to true is called
a tautology. Example: (P --> Q) <--> (~P v Q) is a tautology,
because it is true for all possible combinations of true/false
values of P and Q.
Write a program that tells you if the expression entered is a
tautology or not. Assume that you have no more than three
propositional symbols in your expressions -- call them P, Q, R.
You must use the linked list implementation of the data
structures needed.
Must submit all .java files and outputs -- at least two test
cases, for tautology, and not a tautology.
Problem 2.
Given the following postorder and inorder traversals of a binary
tree, draw the tree:
Postorder: A B C D E F I K J G H
Inorder: C B A E D F H I G K J
Explain your answer in a systematic and recursive fashion.