Академический Документы
Профессиональный Документы
Культура Документы
___________________________________________________________
Name ________Samuel Gbafa_______________________ Date _______________________
Section _________________________________________
Place a check mark in the Assigned column next to the exercises your instructor has assigned to
you. Attach this cover sheet to the front of the packet of materials you submit following the
laboratory.
Activities
Implementation Testing
Assigned: Check or
list exercise numbers Completed
Programming Exercise 1
Programming Exercise 2
Programming Exercise 3
Analysis Exercise 1
Analysis Exercise 2
Total
Check with your instructor whether you are to complete this exercise prior to your lab period or
during lab.
Arithmetic expression
One operator
+34
Nested operators
*+34/52
-/*9321
Uneven nesting
*4+6-75
Zero dividend
/02
Single-digit number
Expected result
Checked
Logic expression
One operator
+10
Nested operators
*+10+01
+*10*1-0
NOT (subexpression)
+-1-*11
-*+110
Double negation
--1
Boolean value
Expected result
Checked
C = *XY
S = +*XY*XY
*00 =
+*00*00 =
*01 =
+*01*01 =
*10 =
+*10*10 =
*11 =
+*11*11 =
Checked
Arithmetic expression
Expected result
Checked
/86
8/6
1.333333333
True
*87
8*7
54
True
*+23-51
(2+3)*(5-1)
20
True
**+632/93
(6+3)*2)*(9/3)
54
True
/*89-52
(8*9)/(5-2)
24
True
Arithmetic
Expression #1
Arithmetic
Expression #2
Expected
result
Checked
/10
(1/0) = inf
(0/1) = 0
No
Yes
*+52+63
((5+2)*(6+3)) = 63
Yes
Yes
-/63/21
((6/3)-(2/1)) = 0
((3+6)*(2+5)) =
63
((1/2)-(3/6)) = 0
No
Yes
What type of tree traversal (inorder, preorder, or postorder) serves as the basis of your
implementation of each of the following Expression Tree ADT operations? Briefly explain why
you used a given traversal to implement a particular operation.
Build
Traversal: Pre-order
Explanation:
1. Visit the root
2. Traverse the left
3. Traverse the right
Expression
Traversal: In order
Explanation:
1. Traverse the left
2. Visit the root
3. Traverse the right
Evaluate
Traversal: Post-Order
Explanation:
1. Traverse the left
2. Traverse the right
3. Visit the root
Clear
Traversal: Post-Order
Explanation: Clear first deletes its subtrees, and then deletes itself
If not, why not? If so, how do the functions differ and why might this difference be important?
They should have the same output. They both check for 0. They both would not print anything if
it was zero. Then they print the actual node is it exist. Then they print the right if it exist.