preview

Essay about ICS 241 Exam 2

Satisfactory Essays

ICS-241
M. Bauer
Exam Two
1. Create a binary search tree from the following data which is as balanced as possible.
No leaf node should be more than +/-1 level from any other leaf node. Note: Do not just create a tree from the data encountered in the following order. 78.2, -35.1, 48.2, 12.9,
-14.7, -86.1, 17.4, 92.7, 38.4, -2.8

17.4

-35.1

-86.1

48.2

-14.7

12.9

38.4

-2.8

78.2

92.7

A
B

C

D
G

E
H

I
L

M

J
N

2. Perform a postorder traversal of the tree depicted above.




Traverse its left subtree.
Traverse is right subtree.
Visit the root of the tree.



G, L, H, D, B, M, N, I, E, O, J, P, K, F, C, A

3. Evaluate the following prefix notation expression:
* - * 3 …show more content…

Draw a digital logic circuit for the expression:

8. Find a minimal expansion of

1

1
• xz

1

1

1

+ y z + xz

9. Let G = (V,T,S,P) be the phrase structure grammar with V={0,1,A,B,S}, T={0,1}, and the set of productions P consisting of: S → 0AB, S→ 1B, A → 1B01, B → 100.



a. Either show that 0110001001 belongs to the language generated by G or explain why it does not.
It is “not” possible to show that 0110001001 because we are looking for a string that
“starts” with a “0” and ends with a “1”. Since we can only use production S with starting state S → 0AB, the string created that will not end with a “1” but always will end with a
“0”.
S → 0AB → 01B01B → 0110001100
b. Either show that 1100 belongs to the language generated by G or explain why it does not. We can show that 1100 belongs to language generated by G by using production S with start state S→ 1B to be:
S→ 1B → 1100

10. Draw a finite state machine (with output) represented by the following state table.
State
s0 s1 s2 s3 s4

f(0) s1 s2 s2 s0 s3 f(1) s3 s4 s1 s4 s0 g(0)
0
1
1
0
1

g(1)
1
0
1
0
0

0,0

S0

0,1

S1 1,0

1,1

1,1

S2

0,1

1,0

0,0

S3

1,0

S4

0,1

11. What is

Get Access