Introduction to Algorithms--Part 1 and 2

Part 1:Foundations

Loop invariants(循环不变式): help judging the rightness of algorithm

Chapter 2: Getting Started

2.1 insert sorting

2.2 analyze algorithm

  1. the worst running time: Θ ( n 2 ) \Theta(n^2) Θ(n2)

2.3 design algorithm

  1. insert sorting using incremental method(增量方法)
    complexity: Θ ( n 2 ) \Theta(n^2) Θ(n2)

  2. divide and conquer(分治法)
    Here is a skill to sort cards using this way. place a sentinel card(哨兵卡) to avoid comparing every times.
    complexity: Θ ( n lg ⁡ n ) \Theta(n\lg^n) Θ(nlgn)

Chapter 3: Growth of Functions

3.1 asymptotic sign(渐近记号)

Θ \Theta Θ: asymptotically tight bound (渐近紧确界), pronounced: Theta
O \Omicron O: asymptotically upper bound (渐近上界), pronounced: O
Ω \Omega Ω: asymptotically lower bound (渐近下界), pronounced: Omega
在这里插入图片描述

Chapter 4: Divide-and-Conquer

4.1 maximum subarray problem

  1. using divide and conquer method: Θ ( n l g n ) \Theta(nlgn) Θ(nlgn)
  2. in some case, only use Θ ( n ) \Theta(n) Θ(n) to solve the problem

4.2 Strassen algorithm of matrix multiplication

  1. In practical, sparse matrix (稀疏矩阵) have special algorithms.
  2. In practical, the fast multiple program of dense matrix use Strassen algorithm when the matrix size exceeds a “intersection” value. Once the size is reduced below the intersection value, program will choose a simpler method.

4.3 Solving recurrence(求解递归式)

  1. Substitution method(代入法)
    guess a bound. Then prove it by mathematical induction(数学归纳法)
  2. Recursive tree method(递归树法)
    Convert recurrence to recursive tree. Then solve it.
  3. Master Theorem(主定理)
    provides a recipe solution for the following form of recurrence:
    T ( n ) = a T ( n / b ) + f ( n ) T(n)=aT(n/b)+f(n) T(n)=aT(n/b)+f(n)
    a ≥ 1 a≥1 a1 and b > 1 b>1 b>1 are constants, f ( n ) f(n) f(n) is asymptotic positive function, T ( n ) T(n) T(n) is a recurrence defined on nonnegative integers.
    == For a constant ϵ > 0 , f ( n ) = O ( n log ⁡ b a − ϵ ) \epsilon>0, f(n)=\Omicron(n^{\log_b^{a-\epsilon}}) ϵ>0,f(n)=O(nlogbaϵ) , then T ( n ) = Θ ( n log ⁡ b a ) T(n)=\Theta(n^{\log_b^a}) T(n)=Θ(nlogba).
    == f ( n ) = Θ ( n log ⁡ b a ) f(n)=\Theta(n^{\log_b^a}) f(n)=Θ(nlogba), then T ( n ) = Θ ( n log ⁡ b a lg ⁡ n ) T(n)=\Theta(n^{\log_b^a}\lg^n) T(n)=Θ(nlogbalgn).
    == For a constant ϵ > 0 , f ( n ) = Ω ( n log ⁡ b a + ϵ ) \epsilon>0,f(n)=\Omega(n^{\log_b^{a+\epsilon}}) ϵ>0,f(n)=Ω(nlogba+ϵ), and, for a constant c < 1 c<1 c<1 and all enough big n, have a f ( n / b ) ≤ c f ( n ) af(n/b)≤cf(n) af(n/b)cf(n), then T ( n ) = Θ ( f ( n ) ) T(n)=\Theta(f(n)) T(n)=Θ(f(n)).

Chapter 5: Probabilistic Analysis and Randomized Algorithms

5.2 Indicator Random Variable(指示器随机变量)

Part 2: Sorting and Order Statistics

在这里插入图片描述

Chapter 6: Heapsort(堆排序)

6.1 Heap

As figure 6-1, (binary) heap is array, it can be regarded as binary tree. The root of tree is A[1], so give a element’s index i, we can calculate its parent / left child / right child node:

PARENT(i)
1	return floor(i / 2)

LEFT(i)
1	return 2i

RIGHT(i)
1	return 2i + 1

在这里插入图片描述

Figure 6-1

binary heap has two forms: max-heap (最大堆) and min-heap (最小堆).

max-heap: all node except root need to satisfy

A[PARENT(i)] ≥ A[i]

min-heap: all node except root node need to satisfy

A[PARENT(i)] ≤ A[i]

The common operations involving heaps are:

  • MAX-HEAPIFY(A, i): complexity O ( l g n ) \Omicron(lgn) O(lgn), key of maintain max-heap property.
  • BUILD-MAX-HEAP(A): complexity O ( n ) \Omicron(n) O(n), function is constructing a max-heap from a disorder array A.
  • HEAPSORT(A): complexity O ( n l g n ) \Omicron(nlgn) O(nlgn), function is sorting a array A in place.
  • MAX-HEAP-INSERT / HEAP-EXTRACT-MAX / HEAP-INCREASE-KEY / HEAP-MAXIMUM: complexity O ( l g n ) \Omicron(lgn) O(lgn), function is use heap to construct a priority-queue

The C++ Standard Library provides the make_heap, push_heap and pop_heap algorithms for heaps.

Chapter 7: Quicksort

Quicksort is usually best choice in practice. The reason is below:

  1. good average performance: expected time complexity Θ ( n l g n ) \Theta(nlgn) Θ(nlgn), and the implicit constant factor is very small.
  2. sorting in place
  3. work well in virtual memory environment

Chapter 8: Sorting in Linear Time

8.3 Counting Sort(计数排序)

Array A[1…n] is input. B[1…n] store the result of sorting, C[0…k] is count array. complexity: Θ ( n ) \Theta(n) Θ(n).

COUNTING-SORT(A, B, k)
1	let C[0..k] = 0 be a new array
2	for j = 1 to A.length
3		C[A[j]] = C[A[j]] + 1
4	// C[i] now contains the number of elements equal to i.
5	for i = 1 to k
6		C[i] = C[i] + C[i-1]
7	// C[i] now contains the number of elements less than or equal to i.
8	for j = A.length downto 1	// note: this is for the stability of counting sort
9		B[C[A[j]]] = A[j]
10	C[A[j]] = C[A[j]] - 1

the figure is the process of above pseudo code.
在这里插入图片描述

8.3 Radix Sort(基数排序)

在这里插入图片描述

8.4 Bucket Sort(桶排序)

在这里插入图片描述
在这里插入图片描述

Chapter 9: Medians and Order Statistics

The i-th order statistic(顺序统计量) is the i-th smallest element of set.

9.1 Minimum and Maximum

When we want to find minimum and maximum, there is a skill that only need 3*floor(n/2) comparisons at most.
Handling input element in pair

  1. compare a pair of input elements, get smaller value and higher value
  2. compare smaller value with current minimum
  3. compare higher value with current maximum

9.2 Select Algorithm of Linear Time Expectation

The function can return i-th smallest element of array A[p…r]. Expection running time: Θ ( n ) \Theta(n) Θ(n).

RANDOMIZED-SELECT(A, p, r, i)
1	if p == r 
2		return A[p]
3	q = RANDOMIZED-PARTITION(A, p, r) // the function is the same as randonmized quick sort algorithm
4	k = q - p + 1
5	if i == k	// the privot value is the answer
6		return A[q]
7	else if i < k
8		return RANDOMIZED-SELECT(A, p, q-1, i)
9	else
10		return RANDOMIZED-SELECT(A, q+1, r, i-k)

9.3 Select Algorithm of Linear Time in Worst Case

Through follow steps, SELECT algorithm can determine i-th smallest element.

  1. dividing n elements of input array into floor(n / 5) groups, every groups have 5 elements, the last group has (n mod 5) elements.
  2. find medians of the ceil(n/5) groups: firstly using insert sort for each group, then determine medians of the groups
  3. For the ceil(n/5) medians finding in step 2, recursively call SELECT to find the median x of the medians(If the number is even, convention x is the smaller median for convenient).
  4. use modified PARTITION function to part input array by median x. Let k be one more than elements’ number in lower part of the partition, so the x is the k-th smallest element, and have (n - k) elements in high part.
  5. If i = k, return x. If i < k, recursively call SELECT to find i-th smallest element in lower part. If i > k, recursively find (i-k)-th smallest element in high part.

note: modified PARTITION function is from determine PARTITION of quick-sort. The modification is taking pivot element as input parameter.

This is my realization. Just simple test, may be have problem.

#include <vector>
#include <list>
using namespace std;

int PARTITION(vector<int>& a, int p, int r, int x)
{
	int j = p-1, k = p-1;
	for (int i = p; i <= r; ++i)
	{
		if (a[i] < x)
		{
			++j;
			++k;
			int tmp = a[j];
			a[j] = a[i];
			a[i] = a[k];
			a[k] = tmp;
		}
		else if (a[i] == x)
		{
			++k;
			int tmp = a[i];
			a[i] = a[k];
			a[k] = tmp;
		}
	}

	return j + 2 - p;
}

// O(n^2)
void insertSort(vector<int> &a)
{
	for (int i = 1; i < a.size(); ++i)
	{
		for (int j = i - 1; j >= 0; --j)
		{
			if (a[j+1] < a[j])
			{
				int tmp = a[j+1];
				a[j+1] = a[j];
				a[j] = tmp;
			}
			else
				break;
		}
	}
}

int SELECT(vector<int> &a, int p, int r, int i)
{
	vector<int> medians;

	if (p == r) return a[p];
	if (p > r) return 0;

	vector<int> tmp;

	for (int i = p; i <= r; ++i)
	{
		if (tmp.size() == 5)
		{
			insertSort(tmp);
			medians.push_back(tmp[2]);
			tmp.clear();
		}
		
		tmp.push_back(a[i]);
	}

	// calculate the last group median
	if (!tmp.empty())
	{
		insertSort(tmp);
		int med = (tmp.size() - 1) / 2;
		medians.push_back(tmp[med]);
	}

	// find median of medians
	int rightBound = medians.size() - 1;
	int x = SELECT(medians, 0, rightBound, rightBound / 2);

	int k = PARTITION(a, p, r, x);

	if (i == k)
		return x;
	else if (i < k)
		return SELECT(a, p, p+k-2, i);
	else
		return SELECT(a, p+k, r, i-k);
}

int main()
{
	vector<int> a = {1, 7, 3, 1, 0, 9};
	int outValue = SELECT(a, 0, a.size()-1, 4);

	return 0;
}
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
本书自第一版出版以来,已经成为世界范围内广泛使用的大学教材和专业人员的标准参考手册。本书全面论述了算法的内容,从一定深度上涵盖了算法的诸多方面,同时其讲授和分析方法又兼顾了各个层次读者的接受能力。各章内容自成体系,可作为独立单元学习。所有算法都用英文和伪码描述,使具备初步编程经验的人也可读懂。全书讲解通俗易懂,且不失深度和数学上的严谨性。第二版增加了新的章节,如算法作用、概率分析与随机算法、线性编程等,几乎对第一版的各个部分都作了大量修订。学过计算机的都知道,这本书是全世界最权威的算法课程的大学课本了,基本上全世界的名牌大学用的教材都是它。这本书一共四位作者,Thomas H. Cormen,Charles E. Leiserson和Ronald L. Rivest是来自MIT的教授,Clifford Stein是MIT出来的博士,现在哥伦比亚大学做教授,四人姓氏的首字母联在一起即是此书的英文简称(CLRS 2e),其中的第三作者Ronald L. Rivest是RSA算法的老大(算法名字里面的R即是指他),四个超级大牛出的一本书,此书不看人生不能算完整。再介绍一下课堂录像里面授课的两位MIT的老师,第一位,外表“绝顶聪明”的,是本书的第二作者Charles E. Leiserson,以逻辑严密,风趣幽默享誉MIT。第二位,留着金黄色的络腮胡子和马尾发的酷哥是Erik Demaine,21岁即取得MIT教授资格的天才,1981出生,今年才25岁,业余爱好是俄罗斯方块、演戏、琉璃、折纸、杂耍、魔术和结绳游戏。另外,附上该书的中文电子版,pdg转pdf格式,中文版翻译自该书的第一版,中文书名没有使用《算法导论》,而使用的是《现代计算机常用数据结构和算法》,1994年出版时没有得到国外的授权,属于“私自翻译出版”,译者是南京大学计算机系的潘金贵。
中文名: 算法导论 原名: Introduction to Algorithms 作者: Thomas H. Cormen Ronald L. Rivest Charles E. Leiserson Clifford Stein 资源格式: PDF 版本: 文字版 出版社: The MIT Press书号: 978-0262033848发行时间: 2009年09月30日 地区: 美国 语言: 英文 简介: 内容介绍: Editorial Reviews Review "In light of the explosive growth in the amount of data and the diversity of computing applications, efficient algorithms are needed now more than ever. This beautifully written, thoughtfully organized book is the definitive introductory book on the design and analysis of algorithms. The first half offers an effective method to teach and study algorithms; the second half then engages more advanced readers and curious students with compelling material on both the possibilities and the challenges in this fascinating field." —Shang-Hua Teng, University of Southern California "Introduction to Algorithms, the 'bible' of the field, is a comprehensive textbook covering the full spectrum of modern algorithms: from the fastest algorithms and data structures to polynomial-time algorithms for seemingly intractable problems, from classical algorithms in graph theory to special algorithms for string matching, computational geometry, and number theory. The revised third edition notably adds a chapter on van Emde Boas trees, one of the most useful data structures, and on multithreaded algorithms, a topic of increasing importance." —Daniel Spielman, Department of Computer Science, Yale University "As an educator and researcher in the field of algorithms for over two decades, I can unequivocally say that the Cormen book is the best textbook that I have ever seen on this subject. It offers an incisive, encyclopedic, and modern treatment of algorithms, and our department will continue to use it for teaching at both the graduate and undergraduate levels, as well as a reliable research reference." —Gabriel Robins, Department of Computer Science, University of Virginia Product Description Some books on algorithms are rigorous but incomplete; others cover masses of material but lack rigor. Introduction to Algorithms uniquely combines rigor and comprehensiveness. The book covers a broad range of algorithms in depth, yet makes their design and analysis accessible to all levels of readers. Each chapter is relatively self-contained and can be used as a unit of study. The algorithms are described in English and in a pseudocode designed to be readable by anyone who has done a little programming. The explanations have been kept elementary without sacrificing depth of coverage or mathematical rigor. The first edition became a widely used text in universities worldwide as well as the standard reference for professionals. The second edition featured new chapters on the role of algorithms, probabilistic analysis and randomized algorithms, and linear programming. The third edition has been revised and updated throughout. It includes two completely new chapters, on van Emde Boas trees and multithreaded algorithms, and substantial additions to the chapter on recurrences (now called "Divide-and-Conquer"). It features improved treatment of dynamic programming and greedy algorithms and a new notion of edge-based flow in the material on flow networks. Many new exercises and problems have been added for this edition. As of the third edition, this textbook is published exclusively by the MIT Press. About the Author Thomas H. Cormen is Professor of Computer Science and former Director of the Institute for Writing and Rhetoric at Dartmouth College. Charles E. Leiserson is Professor of Computer Science and Engineering at the Massachusetts Institute of Technology. Ronald L. Rivest is Andrew and Erna Viterbi Professor of Electrical Engineering and Computer Science at the Massachusetts Institute of Technology. Clifford Stein is Professor of Industrial Engineering and Operations Research at Columbia University. 目录: Introduction 3 1 The Role of Algorithms in Computing 5 1.1 Algorithms 5 1.2 Algorithms as a technology 11 2 Getting Started 16 2.1 Insertion sort 16 2.2 Analyzing algorithms 23 2.3 Designing algorithms 29 3 Growth of Functions 43 3.1 Asymptotic notation 43 3.2 Standard notations and common functions 53 4 Divide-and-Conquer 65 4.1 The maximum-subarray problem 68 4.2 Strassen's algorithm for matrix multiplication 75 4.3 The substitution method for solving recurrences 83 4.4 The recursion-tree method for solving recurrences 88 4.5 The master method for solving recurrences 93 4.6 Proof of the master theorem 97 5 Probabilistic Analysis and Randomized Algorithms 114 5.1 The hiring problem 114 5.2 Indicator random variables 118 5.3 Randomized algorithms 122 5.4 Probabilistic analysis and further uses of indicator random variables 130 II Sorting and Order Statistics Introduction 147 6 Heapsort 151 6.1 Heaps 151 6.2 Maintaining the heap property 154 6.3 Building a heap 156 6.4 The heapsort algorithm 159 6.5 Priority queues 162 7 Quicksort 170 7.1 Description of quicksort 170 7.2 Performance of quicksort 174 7.3 A randomized version of quicksort 179 7.4 Analysis of quicksort 180 8 Sorting in Linear Time 191 8.1 Lower bounds for sorting 191 8.2 Counting sort 194 8.3 Radix sort 197 8.4 Bucket sort 200 9 Medians and Order Statistics 213 9.1 Minimum and maximum 214 9.2 Selection in expected linear time 215 9.3 Selection in worst-case linear time 220 III Data Structures Introduction 229 10 Elementary Data Structures 232 10.1 Stacks and queues 232 10.2 Linked lists 236 10.3 Implementing pointers and objects 241 10.4 Representing rooted trees 246 11 Hash Tables 253 11.1 Direct-address tables 254 11.2 Hash tables 256 11.3 Hash functions 262 11.4 Open addressing 269 11.5 Perfect hashing 277 12 Binary Search Trees 286 12.1 What is a binary search tree? 286 12.2 Querying a binary search tree 289 12.3 Insertion and deletion 294 12.4 Randomly built binary search trees 299 13 Red-Black Trees 308 13.1 Properties of red-black trees 308 13.2 Rotations 312 13.3 Insertion 315 13.4 Deletion 323 14 Augmenting Data Structures 339 14.1 Dynamic order statistics 339 14.2 How to augment a data structure 345 14.3 Interval trees 348 IV Advanced Design and Analysis Techniques Introduction 357 15 Dynamic Programming 359 15.1 Rod cutting 360 15.2 Matrix-chain multiplication 370 15.3 Elements of dynamic programming 378 15.4 Longest common subsequence 390 15.5 Optimal binary search trees 397 16 Greedy Algorithms 414 16.1 An activity-selection problem 415 16.2 Elements of the greedy strategy 423 16.3 Huffman codes 428 16.4 Matroids and greedy methods 437 16.5 A task-scheduling problem as a matroid 443 17 Amortized Analysis 451 17.1 Aggregate analysis 452 17.2 The accounting method 456 17.3 The potential method 459 17.4 Dynamic tables 463 V Advanced Data Structures Introduction 481 18 B-Trees 484 18.1 Definition of B-trees 488 18.2 Basic operations on B-trees 491 18.3 Deleting a key from a B-tree 499 19 Fibonacci Heaps 505 19.1 Structure of Fibonacci heaps 507 19.2 Mergeable-heap operations 510 19.3 Decreasing a key and deleting a node 518 19.4 Bounding the maximum degree 523 20 van Emde Boas Trees 531 20.1 Preliminary approaches 532 20.2 A recursive structure 536 20.3 The van Emde Boas tree 545 21 Data Structures for Disjoint Sets 561 21.1 Disjoint-set operations 561 21.2 Linked-list representation of disjoint sets 564 21.3 Disjoint-set forests 568 21.4 Analysis of union by rank with path compression 573 VI Graph Algorithms Introduction 587 22 Elementary Graph Algorithms 589 22.1 Representations of graphs 589 22.2 Breadth-first search 594 22.3 Depth-first search 603 22.4 Topological sort 612 22.5 Strongly connected components 615 23 Minimum Spanning Trees 624 23.1 Growing a minimum spanning tree 625 23.2 The algorithms of Kruskal and Prim 631 24 Single-Source Shortest Paths 643 24.1 The Bellman-Ford algorithm 651 24.2 Single-source shortest paths in directed acyclic graphs 655 24.3 Dijkstra's algorithm 658 24.4 Difference constraints and shortest paths 664 24.5 Proofs of shortest-paths properties 671 25 All-Pairs Shortest Paths 684 25.1 Shortest paths and matrix multiplication 686 25.2 The Floyd-Warshall algorithm 693 25.3 Johnson's algorithm for sparse graphs 700 26 Maximum Flow 708 26.1 Flow networks 709 26.2 The Ford-Fulkerson method 714 26.3 Maximum bipartite matching 732 26.4 Push-relabel algorithms 736 26.5 The relabel-to-front algorithm 748 VII Selected Topics Introduction 769 27 Multithreaded Algorithms Sample Chapter - Download PDF (317 KB) 772 27.1 The basics of dynamic multithreading 774 27.2 Multithreaded matrix multiplication 792 27.3 Multithreaded merge sort 797 28 Matrix Operations 813 28.1 Solving systems of linear equations 813 28.2 Inverting matrices 827 28.3 Symmetric positive-definite matrices and least-squares approximation 832 29 Linear Programming 843 29.1 Standard and slack forms 850 29.2 Formulating problems as linear programs 859 29.3 The simplex algorithm 864 29.4 Duality 879 29.5 The initial basic feasible solution 886 30 Polynomials and the FFT 898 30.1 Representing polynomials 900 30.2 The DFT and FFT 906 30.3 Efficient FFT implementations 915 31 Number-Theoretic Algorithms 926 31.1 Elementary number-theoretic notions 927 31.2 Greatest common divisor 933 31.3 Modular arithmetic 939 31.4 Solving modular linear equations 946 31.5 The Chinese remainder theorem 950 31.6 Powers of an element 954 31.7 The RSA public-key cryptosystem 958 31.8 Primality testing 965 31.9 Integer factorization 975 32 String Matching 985 32.1 The naive string-matching algorithm 988 32.2 The Rabin-Karp algorithm 990 32.3 String matching with finite automata 995 32.4 The Knuth-Morris-Pratt algorithm 1002 33 Computational Geometry 1014 33.1 Line-segment properties 1015 33.2 Determining whether any pair of segments intersects 1021 33.3 Finding the convex hull 1029 33.4 Finding the closest pair of points 1039 34 NP-Completeness 1048 34.1 Polynomial time 1053 34.2 Polynomial-time verification 1061 34.3 NP-completeness and reducibility 1067 34.4 NP-completeness proofs 1078 34.5 NP-complete problems 1086 35 Approximation Algorithms 1106 35.1 The vertex-cover problem 1108 35.2 The traveling-salesman problem 1111 35.3 The set-covering problem 1117 35.4 Randomization and linear programming 1123 35.5 The subset-sum problem 1128 VIII Appendix: Mathematical Background Introduction 1143 A Summations 1145 A.1 Summation formulas and properties 1145 A.2 Bounding summations 1149 B Sets, Etc. 1158 B.1 Sets 1158 B.2 Relations 1163 B.3 Functions 1166 B.4 Graphs 1168 B.5 Trees 1173 C Counting and Probability 1183 C.1 Counting 1183 C.2 Probability 1189 C.3 Discrete random variables 1196 C.4 The geometric and binomial distributions 1201 C.5 The tails of the binomial distribution 1208 D Matrices 1217 D.1 Matrices and matrix operations 1217 D.2 Basic matrix properties 122
Preface This book provides a comprehensive introduction to the modern study of computer algorithms. It presents many algorithms and covers them in considerable depth, yet makes their design and analysis accessible to all levels of readers. We have tried to keep explanations elementary without sacrificing depth of coverage or mathematical rigor. Each chapter presents an algorithm, a design technique, an application area, or a related topic. Algorithms are described in English and in a "pseudocode" designed to be readable by anyone who has done a little programming. The book contains over 230 figures illustrating how the algorithms work. Since we emphasize efficiency as a design criterion, we include careful analyses of the running times of all our algorithms. The text is intended primarily for use in undergraduate or graduate courses in algorithms or data structures. Because it discusses engineering issues in algorithm design, as well as mathematical aspects, it is equally well suited for self-study by technical professionals. In this, the second edition, we have updated the entire book. The changes range from the addition of new chapters to the rewriting of individual sentences. To the teacher This book is designed to be both versatile and complete. You will find it useful for a variety of courses, from an undergraduate course in data structures up through a graduate course in algorithms. Because we have provided considerably more material than can fit in a typical one-term course, you should think of the book as a "buffet" or "smorgasbord" from which you can pick and choose the material that best supports the course you wish to teach. You should find it easy to organize your course around just the chapters you need. We have made chapters relatively self-contained, so that you need not worry about an unexpected and unnecessary dependence of one chapter on another. Each chapter presents the easier material first and the more difficult material later, with section boundaries marking natural stopping points. In an undergraduate course, you might use only the earlier sections from a chapter; in a graduate course, you might cover the entire chapter. We have included over 920 exercises and over 140 problems. Each section ends with exercises, and each chapter ends with problems. The exercises are generally short questions that test basic mastery of the material. Some are simple self-check thought exercises, whereas others are more substantial and are suitable as assigned homework. The problems are more elaborate case studies that often introduce new material; they typically consist of several questions that lead the student through the steps required to arrive at a solution. We have starred (⋆) the sections and exercises that are more suitable for graduate students than for undergraduates. A starred section is not necessarily more difficult than an unstarred one, but it may require an understanding of more advanced mathematics. Likewise, starred exercises may require an advanced background or more than average creativity. To the student We hope that this textbook provides you with an enjoyable introduction to the field of algorithms. We have attempted to make every algorithm accessible and interesting. To help you when you encounter unfamiliar or difficult algorithms, we describe each one in a step-bystep manner. We also provide careful explanations of the mathematics needed to understand the analysis of the algorithms. If you already have some familiarity with a topic, you will find the chapters organized so that you can skim introductory sections and proceed quickly to the more advanced material. This is a large book, and your class will probably cover only a portion of its material. We have tried, however, to make this a book that will be useful to you now as a course textbook and also later in your career as a mathematical desk reference or an engineering handbook. What are the prerequisites for reading this book? • You should have some programming experience. In particular, you should understand recursive procedures and simple data structures such as arrays and linked lists. • You should have some facility with proofs by mathematical induction. A few portions of the book rely on some knowledge of elementary calculus. Beyond that, Parts I and VIII of this book teach you all the mathematical techniques you will need. To the professional The wide range of topics in this book makes it an excellent handbook on algorithms. Because each chapter is relatively self-contained, you can focus in on the topics that most interest you. Most of the algorithms we discuss have great practical utility. We therefore address implementation concerns and other engineering issues. We often provide practical alternatives to the few algorithms that are primarily of theoretical interest. If you wish to implement any of the algorithms, you will find the translation of our pseudocode into your favorite programming language a fairly straightforward task. The pseudocode is designed to present each algorithm clearly and succinctly. Consequently, we do not address error-handling and other software-engineering issues that require specific assumptions about your programming environment. We attempt to present each algorithm simply and directly without allowing the idiosyncrasies of a particular programming language to obscure its essence. To our colleagues We have supplied an extensive bibliography and pointers to the current literature. Each chapter ends with a set of "chapter notes" that give historical details and references. The chapter notes do not provide a complete reference to the whole field of algorithms, however. Though it may be hard to believe for a book of this size, many interesting algorithms could not be included due to lack of space. Despite myriad requests from

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值