Solved-Homework 3- Solution

$35.00 $24.00

Problem 1 Include with this portion of your homework a copy of your two Fibonacci programs, including your memoisation function, from the implementation section. Analyze the time complexity (big-Oh notation) of your memoisation function and also of the two Fibonacci programs. You don’t need to include output from running them, just the python code itself.…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

5/5 – (2 votes)

Problem 1

Include with this portion of your homework a copy of your two Fibonacci programs, including your memoisation function, from the implementation section. Analyze the time complexity (big-Oh notation) of your memoisation function and also of the two Fibonacci programs. You don’t need to include output from running them, just the python code itself. Using this information, explain why the two (or three) programs take different amounts of time to run.

Problem 2

What if you had to write a memoisation function that could not count on a bounded input size. (In the implementation, recall, we told you that you would never see inputs larger than 100.) What would change? What would its running time be then?

Problem 3 (3.1 from text)

Answer the following questions about the tree of Fig. 3.31.

a. Which nodes are leaves?

b. Which node is the root?

c. What is the parent of node C?

d. Which nodes are children of C?

e. Which nodes are ancestors of E?

f. Which nodes are descendants of E?

g. What are the right siblings of D and E?

h. Which nodes are to the left and to the right of G?

i. What is the depth of node C?

j. What is the height of node C

Problem 4 (3.2 from text)

In the tree of Fig. 3.31 how many different paths of length three are there?

 

Problem 5 (3.6 from text)

Place a check in row i and column j if the two conditions represented by row i and column j can occur simultaneously.

Solution

Problem 6 (3.20 from text)

Suppose characters a, b, c, d, e, f have probabilities .07, .09, .12, .22, .23, .27, respectively. Find an optimal Huffman code and draw the Huffman

tree. What is the average code length?

 

Problem 7 (3.21 from text)

Suppose T is a Huffman tree, and that the leaf for symbol a has greater depth than the leaf for symbol b. Prove that the probability of symbol b is no less than that of a.