《Data Structure And Algorithm Analysis In C++》读书笔记二

本文是《Data Structure And Algorithm Analysis In C++》第二章的读书笔记,重点讨论了算法分析的数学背景、模型、分析内容和运行时间计算。介绍了如何估算程序运行时间、降低运行时间,以及算法分析中的递归、矩阵运算、无限内存模型等概念。并举例说明了大O符号在算法复杂度分析中的应用。
摘要由CSDN通过智能技术生成

Chapter 2 Algorithm Analysis

Topics:

*How to estimate the time required for a program.

*How to reduce the running time of a program from days or years to fractions of a second.

*The results of careless use of recursion.

*Very efficient algorithms to raise a number to a power an to compute the greatest common divisor of two numbers.

2.1 Mathematical Background


The definition is to compare the relative rates of growth.

Def1. the growth rate of T(N) <= f(N)  O

Def2. the growth rate of T(N) >-=g(N)  Ω

Def3. the growth rate of T(N) == h(N)   Θ

Def3. the growth rate of T(N) < p(N) o

When we say that T(N) = O(f(N)), we are guaranteeing that the function T(N) grows at a rate no faster than f(N);

thus f(N) is an upper bound on T(N).

when f(N) = Ω(T(N)). T(N) is the lower bound on f(N).

example, N^3 grows faster than N^2, so N^2 = O(N^3) or  N^3 = Ω(N^2)

example, f(N) = N^2  g(N) = 2N^2 grow at the same rate, so both f(N) = O(g(N)) and f(N) = Ω(g(N)) are true.

when two function grow at the same rate, then the decision of whether or not to signify this with Θ() is depend on the particular context.

another example, if g(N) = 2N^2, then we can say thate g(N) = O(N^4), g(N) = O(N^3), and g(N) = O(N^2).

but the last option is the best answer. Writing g(N) = Θ(N^2) says not only that g(N) = O(N^2) but also that the result is as good as possible.



The fourth edition of Data Structures and Algorithm Analysis in C++ describes data structures, methods of organizing large amounts of data, and algorithm analysis, the estimation of the running time of algorithms. As computers become faster and faster, the need for programs that can handle large amounts of input becomes more acute. Paradoxically, this requires more careful attention to efficiency, since inefficiencies in programs become most obvious when input sizes are large. By analyzing an algorithm before it is actually coded, students can decide if a particular solution will be feasible. For example, in this text students look at specific problems and see how careful implementations can reduce the time constraint for large amounts of data from centuries to less than a second. Therefore, no algorithm or data structure is presented without an explanation of its running time. In some cases, minute details that affect the running time of the implementation are explored. Once a solution method is determined, a program must still be written. As computers have become more powerful, the problems they must solve have become larger and more complex, requiring development of more intricate programs. The goal of this text is to teach students good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amount of efficiency. This book is suitable for either an advanced data structures course or a first-year graduate course in algorithm analysis. Students should have some knowledge of intermediate programming, including such topics as pointers, recursion, and object-based programming, as well as some background in discrete math.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值