Are there F :: * -> *
, iterate' :: Ord a => (a -> a) -> a -> F a
and elem' :: Ord a => Int -> a -> F a -> Bool
with the following properties?
elem x (take n (iterate f y))
⇒elem' n x (iterate' f y)
⇒elem x (iterate f y)
elem' n x (iterate' f y)
runs inO(n * log n)
time andO(n)
spaceelem' n x xs
runs inO(log n)
time andO(1)
space
(Do the intermediate sets count as allocated space? Can you even do finite sets in linear space if you need to balance them?)