16 lines
561 B
Text
16 lines
561 B
Text
a)
|
|
From my understanding, yes, the lists produced are always going to be equal?
|
|
given the same tree
|
|
|
|
b)
|
|
No, they don't, remember than when we `append` two lists, the cons cells for
|
|
the first list have to all be reconstructed, which is an additional O(n)
|
|
steps, where n is len(first-list).
|
|
|
|
This means that when we break up a tree in (tree->list-1 tree) T(n) = T(n/2) +
|
|
O(n) + T(n/2)
|
|
|
|
tree->list-2 has one cons operation, which is constant, for each entry, which
|
|
means the order of growth is O(n)
|
|
|
|
On the other hand, tree->list-1 has order of growth: O(n log n)
|