Space递归函数复杂度分析
Space complexity analysis of recursive functions
在一次典型的面试中,当被问及'what is the space complexity'算法时,如果算法是递归的,面试通常是指'the maximum number of calls on the framestack throughout the life of the algorithm',还是指'the largest number of elements in any given variables created in the function'?
在非递归算法中,后面的定义通常是space复杂度的定义。但是在递归中,我们必须分别定义两者?
如果没有更多信息,'what is the space complexity' 指的是程序使用的总数 space。即栈和堆space.
在一次典型的面试中,当被问及'what is the space complexity'算法时,如果算法是递归的,面试通常是指'the maximum number of calls on the framestack throughout the life of the algorithm',还是指'the largest number of elements in any given variables created in the function'?
在非递归算法中,后面的定义通常是space复杂度的定义。但是在递归中,我们必须分别定义两者?
如果没有更多信息,'what is the space complexity' 指的是程序使用的总数 space。即栈和堆space.