Wednesday, 16 October 2013

Test 1 and Exercise 4!


Today was Test 1 for CSC148. I was extremely nervous about it, and I was especially scared that TreeLists would be on it. I understand the concept of trees, but I just get confused with pre-order and in-order. I’m also confused with the TreeList function that we have to write for Exercise 4. I know how to determine the root and subtrees, however, for e4a.py, I’m not sure how to determine whether a leaf is in Element 1 or 2. For example, if I’m given the pre-oder [10, 6, 8, 12, 11, 15] and the in-order [8, 6, 12, 10, 11, 15], I’m not sure if make_tree( [10, 6, 8, 12, 11, 15], [8, 6, 12, 10, 11, 15]) should produce:

[10, [6, [8, None, None], [12, None, None]], [11, None, [15, None, None]]]
or
[10, [6, [8, None, None], [12, None, None]], [11, [15, None, None], None]].

I’ve asked this question on piazza and I am waiting for a reply.

Continuing my review of Test 1, I didn’t find it too difficult. Question 1 confused me a lot at first, simply because it returned the minimum of the tuple for a given range. At first I thought that this meant that I had to calculate the expression, then find the minimum number in the tuple, and return that number for each i in range(1, n). Later, I realized that I was wrong, and the question was in fact asking to calculate the expression for each i in range(1, n), and then find the smallest tuple and return that tuple. I think and hope that I got the correct answers for Question 1!

No comments:

Post a Comment