[Solved] Given recursive expression, find algorithm with space complexity O(1) [closed]
[ad_1] This sequence is Stern’s diatomic sequence, and the function you’ve been given is called fusc(n). One way to compute it in O(log n) time and O(1) space complexity is to find the n’th value in the Calkin-Wilf tree. That value’s numerator will be fusc(n). You can read some background on the wikipedia page: https://en.wikipedia.org/wiki/Calkin%E2%80%93Wilf_tree … Read more