update thu_dsa/chp4/chp4.md.
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
Conclusion on Chapter Four: Stack & Queue
|
||||
=========================================
|
||||
|
||||
## 知识脉络梳理
|
||||
|
||||
本章主要是讨论了栈(和队列)。借助前面的`Vector`或者`List`,都可以比较轻易地实现两种数据结构,只不过在一些细节上需要在意。栈和队列的基本操作都只需要`O(1)`的时间,它们更多是作为算法设计的基本出发点,来构造更为复杂的算法。因此本章主要是讨论两种数据结构的应用。
|
||||
|
||||
为了用栈或者队列构造其他算法,关键在于把握它们的`LIFO`(栈)或者`FIFO`(队列)的特性。利用栈的特性,可以实现`逆序输出`,`递归嵌套`,`延迟缓冲`以及`试探回溯`的算法。而队列在模拟现实生活中的排队现象中比较有用武之地。
|
||||
|
||||
针对`递归嵌套`问题,本章描述了两个具体的应用,即括号匹配问题与栈混洗问题,这里的关键在于把握两个问题内在的联系,对于两个问题都需要有比较深刻的认识。而`试探回溯`问题则代表了一类算法设计思想:尽量利用问题自身的特性进行剪枝,从而更加高效地找到算法的解,这里的关键在于把握`准绳`和`粉笔`两个工具。
|
||||
|
||||
## 栈的实现
|
||||
|
||||
栈的实现用`Vector`或者用`List`都是无所谓的,直接一个`public`的继承就可以了。想说的是如果用`Vector`实现的话注意一下栈顶和栈尾的选择,把栈尾选到`Vector`的起始处,这样压栈和弹栈操作就都是在`Vector`的末端操作,时间复杂度都是$O(1)$。
|
||||
|
||||
2
words.md
2
words.md
@@ -1501,7 +1501,7 @@ Some Words
|
||||
- The party was derided as totally lacking in ideas.
|
||||
|
||||
+ preoccupation
|
||||
> (n)a state when someone thinks or worries about something a lot, with the result that they do not pat attention to other things.</br>
|
||||
> (n)a state when someone thinks or worries about something a lot, with the result that they do not pay attention to other things.</br>
|
||||
> (n)something that you give all your attention to
|
||||
|
||||
- the current preoccupation with sex and scandal
|
||||
|
||||
Reference in New Issue
Block a user