第3版 Java软体结构与数据结构


第3版 Java软体结构与数据结构

文章插图
Java软体结构与数据结构(第3版)【第3版 Java软体结构与数据结构】根据使用了前两版的教师和学生的反馈 , 作者在第3版中进行了重大修改 , 以适应教学的需要 。本书是着名作者John Lewis与Joseph Chase作为其一流的CSI教材“Java Software Solutions:Foundations of Program Design”的姊妹篇 。儘管本书的英文名为“Java Software Structures:Designing and Using Data Structures” , 但正如作者在前言中所说的那样 , 本书其实是一本可作为“数据结构与算法”课程的教材 。
基本介绍书名:Java软体结构与数据结构(第3版)
ISBN:9787302205951
定价:49元
装帧:平装
图书简介最重要的修改包括这样几个方面:(1)对本书的基本结构进行了重新设计 , 以使得这些内容之间的脉络更加清晰;(2)第3版把对面向对象概念的複习作为一个附录以供参考;(3)上一版给出了几个完整的Java程式设计案例和原始码 , 在第3版中进行了删除 , 并把这几个程式案例原始码放在了网上供读者下载 。译者认为 , 这不仅压缩了不少篇幅 , 而且使得本书更像是一本数据结构与算法的教材 , 而不是Java程式设计的教材;(4)第3版扩展了对图的讨论 , 把“图”与“散列”两章的顺序进行了调换 , 使得脉络更清晰 。本版还添加了一章来专门讨论Set与Map集合 。总之 , 这些修改都是建立在使用以前版本教学的基础上 , 为教师提供更多的机会和更好的灵活性来使用本书 。图书目录ContentsPrefaceChapter 1 Introduction 11 .1 Soffware Quality 2Correctness 3Reliability 3Robustness 4Usability 4Maintainability SReusability SPortability 6Efficiency 6Quality Issues 61.2 Data Structures 7A Physical Example 7Containers as Objects 10Chapter 2 Analysis of Algorithms 132.1 Algorithm Efficiency 142.2 Growth Functions and Big-OH Notation 152.3 Comparing Growth Functions 172.4 Determining Time Complexity 19Analyzing Loop Execution 19Nested Loops 20Method Calls 21Chapter 3 Collections 273.1 Introduction to Collections 28Abstract Data Types 29The Java Collections API 31xv.xvi CONTENTSx o A sfack Collection 31o.2 A Stack Collection 31~ - ~..x' Crucial OO Concert.c 9'o'3 Crucial OO Concepts 33Inheritance 34Class Hierarchies 36m'foe Object Class 37PolymorDhism 38ymorphism 38References and Class Hierarchies 38Generics 40.o.4 A Stock ADT 41Interfaces 41~ -... CI.. -.... c Usina tfacks: Evaluatina prtcfflv Io.5 Usina Stacks: Evaluatina Posffix Exoressions 44s stacks: Evaluating Posffix Expressions 44-' -... ^ ac~eptions 51o.6 Exceptions 51Exception Messages 52~,foe try Statement S3Exception Propagation 54- 'f..x. lmrilementina a Stack: With Array ''o.7 implementing a Stack: With Arrays 55Managing Capacity 56- o -.x R The Arral'q.-" Class 57o.8 The Arraystack Class 57FIfoe Constructors 58al.foe push Operation 59FIfoe pop Operation 61al.foe peek Operation 62Other Operations 63Chapter 4 Linked Structures 714.1 References as Links 724.2 Managing Linked Lists 74 Accessing Elements 74Inserting Nodes 7SDeleting Nodes 76sentinel Nodes 77sentinel Nodes 774.3 Elements Without Links 78Doublv Linked Lists 78y Linked Lists 784.4 implementing a Stock: With Links 79FIfoe LinkedStack Class 79CONTENTS xviim['f he push Operation 83FIf he pop Operation 85Other Operations 864.5 Usina Stacks: Traversina a Maze 86u clacks: Traversing a Maze 864.6 Implementing Stacks:The java. util. stack Class 93Unique Operations 93Inheritance and Implementation 94Chapter 5 Queues 995.1 A Queue ADT 1005 o llcina Queues: Code Ke\'c Inka'2 Using Queues: Code Keys 103s Queues: Code Keys 1035. llcina Queues: Ticket Counter Simulation 107a.3 Using Queues: Ticket Counter Simulation 107u Queues: Ticket Counter Simulation 1075 4 lmrilementina Queues: With Links 112a.4 implementing Queues: With Links 112FIf he enque Operation 114al,f he dequeue Operation 115Other Operations 1175.5 Implementing Queues: With Arrays 117FIf he enqueue Operation 123m,f he dequeue Operation 124 Other Operations 125Chapter 6 Lists 1316.1 A List ADT 132Iterators 134Adding Elements to a List 135Interfaces and PolymorDhism 137; Inorphism 1376'2 Using Ordered Lists: TOurnament Maker 140d6'3 Using indexed Lists: The Joseohus Problem 150u indexed Lists: The Josephus Problem 1506.4 Implementing Lists: With Arrays 152FIl he remove Operation ISSFIl he contains Operation IS7al.f he iterator Operation IS8al.f he add Operation for an Ordered List IS8peration for an Ordered List IS8...xvill CO NTE NTSOperations Particular to Unordered Lists 161ml,,,foe addAfter Operation for an Unordered List 1626.5 Implementing Lists: With Links 163FIfoe remove Operation 163Doubly Linked Lists 165y Linked Lists 165al.foe iterator Operation 1686.6 Lists in the Java Collections API 171Cloneable 172c., i - =hi e 172berializable 172RandomAccess 172Tova. util. Vector 173Java. util. Vector 173Tova. util. ArralrT' o- 1 72Java. util. ArrayList 173Tova. util. LinkedList 176Java. util. LinkedList 176Chapter 7 Recursion 185 -f, -. -I... -7.1 Recursive Thinking 1869 186Infinite Recursion 186Recursion in Math 1877.2 Recursive Programming 188"ramming 188Recursion versus iteration 190Direct versus indirect Recursion 191-.7.3 Using Recursion 192. Recursion 192m. A' 4 Q,lraversing a Maze 192al m r T T. 4Of he Towers of Hanoi 1977.4 Analyzing Recursive Algorithms 201Chapter & Sorting and Searching 2098.1 Searchinq 2109 210static Methods 211static Methods 211Generic Methods 211Linear Search 212Binary Search 213y search 213Comparing Search Algorithms 2168.2 Sortina 2179 217Selection Sort 220selection Sort 220Insertion Sort 222CO NTE NTS xlxBubble Sort 224Quick sort 226Merge Sort 2298.3 Radix Sort 231Chapter 9 Thees 2419'1 Thees 242mfree Classifications 2439'2 Strateaies for Imolementina Thees 245stes for Implementing Thees 245Commutational Strategy forputational Strategy forArray ImDlementation of Trees 245j implementation of Trees 245simulated Link Strate21r forsimulated Link Strategy forArray ImDlementation of Trees 246, implementation of Trees 246Analtsis of Trees 247 9.3 Thee TFaversals 248Preorder Traversal 248Inorder Traversal 249Postorder Traversal 249Level-Order Traversal 2509.4 A Binary Thee ADT 2519.5 Usina Binary Thees: Exoression TFees 255s Binary Thees: Expression TFees 2559.6 Implementing Binary Thees with Links 262FIfoe find Method 269ml.,foe iteratorlnorder Method 2709.7 implementing Binary Thees with Arrays 271FIfoe find Method 273ac. h' I I ry-'foe iteratorlnorder Method 274Chapter 10 Binary Search Thees 28110.1 A Binary Search Thee 28210.2 Implementing Binary Search Thees:With Links 284alefoe addElement ODeration 286peration 286FIfoe removeElement Operation 288u CONTENTSFIfoe removeAlloccurrences Operation 291peration 291FIfoe removeMin Operation 29210.3 implementing Binary Search Thees:With Arrays 294ml,,o,foe addElement Operation 295FIfoe removeElement Operation 296FIfoe removeAlloccurrences Operation 302FIfoe removeMin Operation 30310.4 Usina Binary Search Thees:9 Binary Search Thees: implementing Ordered Lists 304Analysis of the BinarySearchTreeList.Implementation 30810.5 Balanced Binary Search Thees 309Right Rotation 310.lit Rotation 310Left Rotation 310Rightleft Rotation 311.iltleft Rotation 311Leftright Rotation 31110.6 implementing Binary Search Thees:AVL Thees 312Right Rotation in an AVL Tree 313.nt Rotation in an AVL Tree 313Left Rotation in an AVL Tree 315Ritthtleft Rotation in an AVL Tree 3iS.ntleft Rotation in an AVL Tree 3iSLeftright Rotation in an AVL Tree 31510.7 Implementing Binary Search Thees:Red/Black Thees 315Insertion into a Red/Black Tree 316Element Removal from a Red/Black Tree 31910.8 Implementing Binary Search Thees:The Java Collections API 32110.9 A Philosophical Quandary 325Chapter 11 Priority Queues and Heaps 33311.1 A Heap 334ml,,foe addElement Operation 334FI.foe removeMin Operation 337FIfoe findMin Operation 33811'2 Usina Heaps: Priority Queues 339. Heaps: Priority Queues 339CO NTE NTS m11.3 implementing Heaps: With Links 343FIfoe addElement Operation 343FIfoe removeMin Operation 346 FIfoe findMin Operation 34911.4 Implementing Heaps: With Arrays 350al.foe addElement Operation 350FIfoe removeMin Operation 352FIfoe findMin Operation 35311'5 Usina Heaos: Heao Sort 354u Heaps: Heap Sort 354Chapter 12 Multi-way Search Thees 36112'1 Combining TFee Conceots 362. rFee Concepts 36212'2 2-3 Thees 362Inserting Elements into a 2-3 Tree 362Removing Elements from a 2-3 Tree 36512'3 2-4 Thees 36912.4 B-Thees 369B*-trees 371B+-trees 372Analysis of B-trees 372yals of B-trees 37212.5 implementation Strategies for B-Thees 373Chapter 13 Graphs 37713.1 Undirected Graphs 37813.2 Directed Graphs 38013.3 Networks 38113'4 Common Graph Algorithms 382~'fraversals 383m.festinZ for Connectivity 387b ior Connectivity 387Minimum Spanning Trees 388DetermininZ the Shortest Path 391o the Shortest Path 39113'5 Strateqies for lmolementina Graohs 392.ies for implementing Graphs 392Adjacency Lists 392jacency Lists 392Adjacency Matrices 393jacency Matrices 393..nil C O NTE NTS 13.6 implementing Undirected Graphs... -..With an Adiocency Motrix 395Jacency Motrix 395al, 'o' A' 1 1 7 OOfoe addEdge Method 399ale .t. t A, I l' unfoe addvertex Method 400FIfoe extendcapacity Method 401Other Methods 401Chapter 14 Hashing 40714.1 Hashing 40814.2 Hashina Functions 4109 Functions 410AL ri'.. h' I l', nfoe Division Method 410al v I l' Method 411foe Folding Method 411al 1 r. I c A' I l' 1 1foe Mid-Square Method 411al n ac l' m c. h' I I' 1,foe Radix Transformation Method 412al ri'.' 1. Method 412foe Digit Analysis Method 412The Length-Dependent Method 412Hashing Functions in the Java Language 41314.3 Resolving Collisions 413Chaining 413Open Addressing 41614.4 Deleting Elements from a Hash Table 419Deleting from a Chained Implementation 420Deleting from an Open AddressingImplementation 42014.5 Hash Tables in the Java Collections API 421FIfoe Hashtable Class 422FIfoe HashSet Class 424FIfoe HashMap Class 424FIfoe ldentityHashMap Class 424FIfoe WeakHashMap Class 425 .LinkedHashSet and LinkedHashMap 428Chapter 15 Sets and Maps 43515.1 A Set Collection 43615.2 Using a Set: Bingo 439CONTENTS "iii15.3 implementing a Set: With Arrays 443~,foe add Operation 445alfoe addAll Operation 447m'foe removeRandom Operation 448FIfoe remove Operation 449al.foe union Operation 450FIfoe contains Operation 451FIfoe equals Operation 452Other Operations 453UML Description 45315.4 implementing a Set: With Links 455ml,, ac.foe add Operation 456FIfoe removeRandom Operation 457FIfoe remove Operation 458Other Operations 45915.5 Maps and the Java Collections API 459Appendix A UML 467al T T. f' I A, I I. T fT T'foe Unified Modeling Language (UML) 468b Language (UML) 468UML Class Diagrams 468UML Relationships 469Appendix B Object-Oriented Design 475B.1 Overview of Object-Orientation 476B.2 Usina Obiects 476S Objects 476Abstraction 477Creating Objects 478B.3 Class Libraries and Packages 480 al. ac 1.foe import Declaration 480B.4 State and Behavior 481B.5 Classes 482Instance Data 485B.6 Encapsulation 486Visibility Modifiers 486Local Data 488.ulv C O N T E N TSB.7 Constructors 488B.8 Method Overloadina 489s 489B.9 References Revisited 490FI 11 o c' onfoe null Reference 490FIl he this Reference 491Aliases 493Garbage Collection 494Passing Objects as Parameters 495B.10 The static Modifier 495static Variables 49sJtatlc Variables 49sstatic Methods 496static Methods 496B.11 Wrapper Classes 497B.12 Interfaces 498al T C' QQfoe Comparable interface 499FI T C adnfoe lterator interface 500B.13 Inheritance 500Derived Classes 501al A' 1. c. on,foe protected Modifier 503al n rfoe super Reference 503Overriding Methods 504B.14 Class Hierarchies 504FIfoe object Class 505Abstract Classes 506Interface Hierarchies 508B.15 Polymorphism 508References and Class Hierarchies 509Polymorphism via inheritance 510y morphism via inheritance 510Polymorphism via interfaces 512 ymorphism via interfaces 512B.16 Generic Types 514B.17 Exceptions 515Exception Messages 515al c'foe try Statement 516Exception Propagation 517al v.foe Exception Class Hierarchy 517Index 527