01 flatten :: Btree a -> [a]
02 flatten (Leaf x) = [x]
03 flatten (Fork xt yt) = flatten xt ++ flatten yt
|
01 flatcat :: Btree a -> [a] -> [a]
02 flatcat xt xs = flatten xt ++ xs
|
01 flatcat :: Btree a -> [a] -> [a]
02 flatcat (Leaf x) xs = x : xs
03 flatcat (Fork xt yt) xs = flatcat xt (flatcat yt xs)
|
T(flatten)(0) = O(1)
T(flatten)(h+1) = 2 T(flatten)(h) + T(++)(2h,2h)
T(flatten)(h) = Θ(h 2h)
T(flatcat)(0,n) = O(1)
T(flatcat)(h+1,n) = O(1) + T(flatcat)(h,2h+n) + T(flatcat)(h,n)
T(flatcat)(h,n) = Θ(2h)