没有合适的资源?快使用搜索试试~ 我知道了~
首页Algorithm And Complexity 《算法和复杂度》(英文版)
Algorithm And Complexity 《算法和复杂度》(英文版)
需积分: 12 21 下载量 163 浏览量
更新于2023-03-03
评论
收藏 986KB PDF 举报
这本书是关于算法和复杂性,因此它在解决问题的方法上 计算机和费用(通常是运行时间),使用这些方法。 计算需要时间。有些问题需要很长的时间其他人就可以迅速完成。一些问题 似乎需要很长时间,然后有人发现一个更快的方法,研究的数额计算端口的是需要的,以便执行某些类型的计算是研究计算复杂性的关键。
资源详情
资源评论
资源推荐
Algorithms and Complexity
Herbert S. Wilf
University of Pennsylvania
Philadelphia, PA 19104-6395
Copyright Notice
Copyright 1994 by Herbert S. Wilf. This material may be reproduced for any educational purpose, multiple
copies may be made for classes, etc. Charges, if any, for reproduced copies must be just enough to recover
reasonable costs of reproduction. Reproduction for commercial purposes is prohibited. This cover page must
be included in all distributed copies.
Internet Edition, Summer, 1994
This edition of Algorithms and Complexity is available at the web site <http://www/cis.upenn.edu/ wilf>.
It may be taken at no charge by all interested persons. Comments and corrections are welcome, and should
be sent to wilf@math.upenn.edu
CONTENTS
Chapter 0: What This Book Is About
0.1Background ......................................1
0.2Hardvs.easyproblems .................................2
0.3Apreview .......................................4
Chapter 1: Mathematical Preliminaries
1.1Ordersofmagnitude ..................................5
1.2Positionalnumbersystems............................... 11
1.3 Manipulations with series ............................... 14
1.4Recurrencerelations.................................. 16
1.5Counting ...................................... 21
1.6Graphs ....................................... 24
Chapter 2: Recursive Algorithms
2.1Introduction ..................................... 30
2.2Quicksort ...................................... 31
2.3 Recursive graph algorithms ............................... 38
2.4 Fast matrix multiplication ............................... 47
2.5ThediscreteFouriertransform ............................. 50
2.6 Applications of the FFT ................................ 56
2.7Areview....................................... 60
Chapter 3: The Network Flow Problem
3.1Introduction ..................................... 63
3.2 Algorithms for the network flow problem ......................... 64
3.3 The algorithm of Ford and Fulkerson .......................... 65
3.4Themax-flowmin-cuttheorem............................. 69
3.5 The complexity of the Ford-Fulkerson algorithm ..................... 70
3.6Layerednetworks................................... 72
3.7 The MPM Algorithm ................................. 76
3.8 Applications of network flow .............................. 77
Chapter 4: Algorithms in the Theory of Numbers
4.1Preliminaries..................................... 81
4.2Thegreatestcommondivisor.............................. 82
4.3 The extended Euclidean algorithm ........................... 85
4.4Primalitytesting ................................... 87
4.5 Interlude: the ring of integers modulo n ......................... 89
4.6Pseudoprimalitytests ................................. 92
4.7Proofofgoodnessofthestrongpseudoprimalitytest.................... 94
4.8 Factoring and cryptography .............................. 97
4.9 Factoring large integers ................................ 99
4.10Provingprimality...................................100
iii
Chapter 5: NP-completeness
5.1Introduction .....................................104
5.2 Turing machines ...................................109
5.3Cook’stheorem....................................112
5.4SomeotherNP-completeproblems ...........................116
5.5Halfaloaf........................................ 119
5.6 Backtracking (I): independent sets ...........................122
5.7 Backtracking (II): graph coloring ............................124
5.8 Approximate algorithms for hard problems . . . .....................128
iv
Preface
For the past several years mathematics majors in the computing track at the University of Pennsylvania
have taken a course in continuous algorithms (numerical analysis) in the junior year, and in discrete algo-
rithms in the senior year. This book has grown out of the senior course as I have been teaching it recently.
It has also been tried out on a large class of computer science and mathematics majors, including seniors
and graduate students, with good results.
Selection by the instructor of topics of interest will be very important, because normally I’ve found
that I can’t cover anywhere near all of this material in a semester. A reasonable choice for a first try might
be to begin with Chapter 2 (recursive algorithms) which contains lots of motivation. Then, as new ideas
are needed in Chapter 2, one might delve into the appropriate sections of Chapter 1 to get the concepts
and techniques well in hand. After Chapter 2, Chapter 4, on number theory, discusses material that is
extremely attractive, and surprisingly pure and applicable at the same time. Chapter 5 would be next, since
the foundations would then all be in place. Finally, material from Chapter 3, which is rather independent
of the rest of the book, but is strongly connected to combinatorial algorithms in general, might be studied
as time permits.
Throughout the book there are opportunities to ask students to write programs and get them running.
These are not mentioned explicitly, with a few exceptions, but will be obvious when encountered. Students
should all have the experience of writing, debugging, and using a program that is nontrivially recursive,
for example. The concept of recursion is subtle and powerful, and is helped a lot by hands-on practice.
Any of the algorithms of Chapter 2 would be suitable for this purpose. The recursive graph algorithms are
particularly recommended since they are usually quite foreign to students’ previous experience and therefore
have great learning value.
In addition to the exercises that appear in this book, then, student assignments might consist of writing
occasional programs, as well as delivering reports in class on assigned readings. The latter might be found
among the references cited in the bibliographies in each chapter.
I am indebted first of all to the students on whom I worked out these ideas, and second to a num-
ber of colleagues for their helpful advice and friendly criticism. Among the latter I will mention Richard
Brualdi, Daniel Kleitman, Albert Nijenhuis, Robert Tarjan and Alan Tucker. For the no-doubt-numerous
shortcomings that remain, I accept full responsibility.
This book was typeset in T
E
X. To the extent that it’s a delight to look at, thank T
E
X. For the deficiencies
in its appearance, thank my limitations as a typesetter. It was, however, a pleasure for me to have had the
chance to typeset my own book. My thanks to the Computer Science department of the University of
Pennsylvania, and particularly to Aravind Joshi, for generously allowing me the use of T
E
X facilities.
Herbert S. Wilf
v
Chapter 0: What This Book Is About
0.1 Background
An algorithm is a method for solving a class of problems on a computer. The complexity of an algorithm
is the cost, measured in running time, or storage, or whatever units are relevant, of using the algorithm to
solve one of those problems.
This book is about algorithms and complexity, and so it is about methods for solving problems on
computers and the costs (usually the running time) of using those methods.
Computing takes time. Some problems take a very long time, others can be done quickly. Some problems
seem to take a long time, and then someone discovers a faster way to do them (a ‘faster algorithm’). The
study of the amount of computational effort that is needed in order to perform certain kinds of computations
is the study of computational complexity.
Naturally, we would expect that a computing problem for which millions of bits of input data are
required would probably take longer than another problem that needs only a few items of input. So the time
complexity of a calculation is measured by expressing the running time of the calculation as a function of
some measure of the amount of data that is needed to describe the problem to the computer.
For instance, think about this statement: ‘I just bought a matrix inversion program, and it can invert
an n × n matrix in just 1.2n
3
minutes.’ We see here a typical description of the complexity of a certain
algorithm. The running time of the program is being given as a function of the size of the input matrix.
A faster program for the same job might run in 0.8n
3
minutes for an n × n matrix. If someone were
to make a really important discovery (see section 2.4), then maybe we could actually lower the exponent,
instead of merely shaving the multiplicative constant. Thus, a program that would invert an n × n matrix
in only 7n
2.8
minutes would represent a striking improvement of the state of the art.
For the purposes of this book, a computation that is guaranteed to take at most cn
3
time for input of
size n will be thought of as an ‘easy’ computation. One that needs at most n
10
time is also easy. If a certain
calculation on an n × n matrix were to require 2
n
minutes, then that would be a ‘hard’ problem. Naturally
some of the computations that we are calling ‘easy’ may take a very long time to run, but still, from our
present point of view the important distinction to maintain will be the polynomial time guarantee or lack of
it.
The general rule is that if the running time is at most a polynomial function of the amount of input
data, then the calculation is an easy one, otherwise it’s hard.
Many problems in computer science are known to be easy. To convince someone that a problem is easy,
it is enough to describe a fast method for solving that problem. To convince someone that a problem is
hard is hard, because you will have to prove to them that it is impossible to find a fast way of doing the
calculation. It will not be enough to point to a particular algorithm and to lament its slowness. After all,
that algorithm may be slow, but maybe there’s a faster way.
Matrix inversion is easy. The familiar Gaussian elimination method can invert an n × n matrix in time
at most cn
3
.
To give an example of a hard computational problem we have to go far afield. One interesting one is
called the ‘tiling problem.’ Suppose* we are given infinitely many identical floor tiles, each shaped like a
regular hexagon. Then we can tile the whole plane with them, i.e., we can cover the plane with no empty
spaces left over. This can also be done if the tiles are identical rectangles, but not if they are regular
pentagons.
In Fig. 0.1 we show a tiling of the plane by identical rectangles, and in Fig. 0.2 is a tiling by regular
hexagons.
That raises a number of theoretical and computational questions. One computational question is this.
Suppose we are given a certain polygon, not necessarily regular and not necessarily convex, and suppose we
have infinitely many identical tiles in that shape. Can we or can we not succeed in tiling the whole plane?
That elegant question has been proved* to be computationally unsolvable. In other words, not only do
we not know of any fast way to solve that problem on a computer, it has been proved that there isn’t any
* See, for instance, Martin Gardner’s article in Scientific American, January 1977, pp. 110-121.
* R. Berger, The undecidability of the domino problem, Memoirs Amer. Math. Soc. 66 (1966), Amer.
剩余138页未读,继续阅读
huangtaiquan
- 粉丝: 4
- 资源: 33
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 数据结构1800题含完整答案详解.doc
- 医疗企业薪酬系统设计与管理方案.pptx
- 界面与表面技术界面理论与表面技术要点PPT学习教案.pptx
- Java集合排序及java集合类详解(Collection、List、Map、Set)讲解.pdf
- 网页浏览器的开发 (2).pdf
- 路由器原理与设计讲稿6-交换网络.pptx
- 火电厂锅炉过热汽温控制系统设计.doc
- 企业识别CIS系统手册[收集].pdf
- 物业管理基础知识.pptx
- 第4章财务预测.pptx
- 《集成电路工艺设计及器件特性分析》——实验教学计算机仿真系.pptx
- 局域网内共享文件提示没有访问权限的问题借鉴.pdf
- 第5章网络营销策略.pptx
- 固井质量测井原理PPT教案.pptx
- 毕业实习总结6篇.doc
- UGNX建模基础篇草图模块PPT学习教案.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0