- 注册
- 2002-10-12
- 消息
- 47,111
- 荣誉分数
- 2,376
- 声望点数
- 393
That might be incorrect. With most of compilers and languages like C++, you could just push the array pointer or reference object into stack and just use the pointer instead of the actual array itself or sub-arrays. You are actually pushing the same memory size of context into a stack.Yeap, that is what I meant. I presume that function calls in any language involve pushing the contexts into stacks. In your recursion code for reversing a string, if the input string has length N, then the (computation) tree should have depth log(N) (base 2). At each depth, your code would presumably push size-N context into a stack. The total memory used should be N log(N) ...
The reversing-string problem should be solvable in O(N) time and O(1) memory. In this sense, the recursion algorithm is not optimal ... if what I wrote above is correct ...![]()
32位 x86方面:
内存大小方面(wchar_t *) = (unsigned int)都是dword的