栈 Flashcards

1
Q

的具象表示

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

计算机调用栈的实例

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

递归函数调用栈的实例

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

调用栈的代价及解决办法

A

使用栈虽然很方便,但是也要付出代价:存储详尽的信息可能占用大量的内存。每个函数调用都要占用一定的内存,如果栈很高,就意味着计算机存储了大量函数调用的信息。

在这种情况下,你有两种选择。
❑ 重新编写代码,转而使用循环。
❑ 使用尾递归。这是一个高级递归主题,不在本书的讨论范围内。另外,并非所有的语言都支持尾递归。

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Stack LIFO explanation

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly