这一章基本上就是忽悠你们努力学习算法:算法是一种经过有限步骤的运算来解决计算问题的方式,blabla...算法和数据结构密切相关。算法是一种技术。好的算法能够比差的算法猛的多,好几个数量级,等等。html
Give a real-world example that requires sorting or a real-world example that requires computing a convex hull.linux
排序,给班上的学生成绩排序,决定他们的爸妈回去打不打他们的屁股。git
计算曲面,游戏或者电影里面用的上吧。github
Other than speed, what other measures of efficiency might one use in a real-world setting?算法
这个问题在公开课上有很好的讨论。空间复杂度(内存和硬盘的占用率),实现方便程度,安全性,容易维护性,等等,都是实际工程须要讨论的。shell
Rob Pike有一篇C语言编程实践,很是精炼,他认为数据结构才是程序的核心,而非算法,中文版在这里。编程
Select a data structure that you have seen previously, and discuss its strengths and limitations.安全
链表,链表的好处在于插入,删除都是O(1)的,固然随机读就不行,是O(n)的。关于链表,我看到linus在网上和人讨论过。这里有2篇文章精妙的讨论了链表做为linux内核的基础数据结构,和怎么经过C语言的特性来减小开销所能作到的:数据结构
How are the shortest-path and traveling-salesman problems given above similar? How are they different?
相同之处: 找一条最短的路。
不一样之处: 最短路径问题的起点和终点是肯定的。邮递员问题不肯定,能够任意选择点的顺序。
Come up with a real-world problem in which only the best solution will do. Then come up with one in which a solution that is “approximately” the best is good enough.
前者,我想到的是语音识别技术,若是不能达到90%以上的识别率,那就没什么大用。听说李开复在这个方面作了不少工做。如今的手机和最新的Google Andriod TV都能很是方便的使用语音识别,很牛。
后者,地图导航,在城市里面有不少路,找到差很少最短的路就能够了,反正都能走么。
Give an example of an application that requires algorithmic content at the application level, and discuss the function of the algorithms involved.
额,老答案,GPS导航,最短路径问题。
Suppose we are comparing implementations of insertion sort and merge sort on the same machine. For inputs of sizen, insertion sort runs in 8n^2 steps, while merge sort runs in 64nlgn steps. For which values of n does insertion sort beat merge sort?
8n^2 = 64nlgn
n = 8lgn
n = 2, 2 < 8
n = 8, 8 < 24
n = 32, 32 < 40
n = 64, 64 > 48
n在32和64之间,后面能够用计算器暴力求解,偷看答案是43。
What is the smallest value of n such that an algorithm whose running time is 100n^2 runs faster than an algorithm whose running time is2^n on the same machine?
100n^2 < 2^n
n = 10, 100*100 < 1024
n = 9, 100*81 > 512
因此n = 10。
Comparison of running times For each function f(n) and time t in the following table, determine the largest sizenof a problem that can be solved in timet, assuming that the algorithm to solve the problem takes f(n) microseconds.
这题是考察美国学生的小学数学计算能力么?太没技术含量啦……
因此我就不作了,嗯
能够到另外一位老兄的习题集里面去看