113x Filetype PDF File size 0.37 MB Source: static1.squarespace.com
Data structures and algorithms in python goodrich pdf The design and analysis of efficient data structures has long been considered a core subject in computer science and is part of the undergraduate program in computer science and the undergraduate program in computer engineering. Data Structures and Algorithms in Python provides an introduction to data structures and algorithms, including their design, analysis, and implementation. This book is intended to be used in an introductory course in data structures or in an advanced algorithm course. We will discuss its use in these courses in more detail later in the preface. To support the development of reliable and reusable software, we have tried to use a consistent object-oriented perspective throughout. One of the key ideas of the object-oriented approach is that data should be represented as a wrapper around the methods that access and modify it. This means that instead of simply thinking of data as a collection of bytes and addresses, we think of data objects as instances of an abstract data type (ADT) that contain a repertoire of methods for performing operations on data objects of that type. We then highlight that a given ADT may have several different deployment strategies and explore the relative pros and cons of these choices. We provide complete Python implementations for almost all of the data structures and algorithms discussed, and introduce important object- oriented design patterns as a means of organizing these implementations into reusable components. The desired outcomes for readers of our book are: ¢ Knowledge of the most common data collection abstractions (eg, stacks, queues, lists, trees, maps). ¢ understands algorithmic strategies for creating effective implementations of common data structures. ¢ can analyze the performance of algorithms both theoretically and experimentally and identify common trade-offs between competing strategies. ¢ They are able to rationally use existing data structures and algorithms found in libraries of modern programming languages. ¢ Have experience working with concrete implementations of most functional data structures and algorithms. ¢ They can use data structures and algorithms to solve complex problems. To support the latter goal, we provide many examples of data structure applications throughout the book, including file system manipulation, tag comparison in structured formats such as HTML, simple cryptography, text frequency analysis,Geometric distribution, Huffman coding, DNA sequencing and search engine indexing. www.it-ebooks.info www.it-ebooks.info Data Structures and Algorithms in Java Sixth Edition Michael T. Goodrich California Department of Computer, Irvine Roberto Computer and Information Science Saint Louis University www. Vice President and Publisher IT-eBooks.info Don Fowley Editor Beth Lang Golub Assistant Marketing Manager Debbie Drive Drive. Kenji Ngging This book was created by latex authors and printed and bound by RR Donnelley. Cover printed by RR Donnelley. Trademark Acknowledgment: Java is a trademark of Oracle Corporation. UNIX ® is a registered trademark in the United States and other countries licensed to X/Open Company, Ltd. PowerPoint is a trademark of Microsoft Corporation. All other product names listed in this document are trademarks of their respective owners. This book is printed on acid-free paper. John Wiley & Sons, Inc. Founded in 1807, it has been a valuable source of knowledge and understanding for over 200 years, helping people around the world meet their needs and fulfill their desires. Our company is built on principles that relate to the responsibility of the communities we serve and where we live and work. In 2008, we launched the Corporate Citizenship Initiative, a global effort to address the environmental, social, economic and ethical issues we face in our business. The issues we tackle are the impact on coal specifications, paper specifications and public procurement, ethical behavior within our company, and our support and advocacy for society and charity. For more information, visit our website: www.wiley.com/go/citizenship. Copyright © 2014, 2010 John Wiley & Sons, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted by section 107 or 108 of 1976. Merging of copyright without the prior written consent of the publisher or permission by paying the appropriate Centrum Coping Center, Inc. 222 Rosewood Drive, Danvers,01923, www.copyright.com. Requests for permission to publish should be sent to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, (201) 748-6011, fax (201) 748-6008, http:// / / / / www. wiley.com/go/permissions. Copies of the assessment are issued to qualified academics and professionals for review purposes only, for use in courses in the next academic year. These copies are licensed and must not be sold or given to third parties. At the end of the review period, give a copy of the assessment to Wiley. Return instructions and a free return label are available at www.wiley.com/go/returnlabel. If you choose to accept this course guide, please accept it as a free copy of your desktop. Outside the US, please contact your local sales representative. ISBN: 978-1118-77133-4 (soft lids) printed in the United States 10 9 8 7 6 5 4 3 2 1 1 www.it-eblox.info Karen, Paul, Anna and Jack Michael T. Goodris at Isabel Roberto Tamassia for Susan, Calista, and Maija-Michal H. Goldwathers www.it-eblooks.info www.it-eblooks.info Sixth Edition Preface to Java Data Structures and Algorithms provides an introduction to data structures and algorithms, including their design, analysis, and analysis . and implementation. The main changes in this sixth edition are as follows: • We have redesigned the entire code base to improve presentation clarity and style consistency and consistency, including relying on type inference introduced in Java 7 to reduce clutter by creating generic types. • Added 38 new numbers and revised 144 existing ones. • We've improved and expanded the exercises with 794 exercises! We continue our approach by dividing them into reinforcement, creative and design exercises. However, we have decided not to reset the numbering scheme with each new category, avoiding possible ambiguity between exercises such as R-7.5, C-7.5, P-7.5. • Introducers include examples of additional classes and inheritance, an extended discussion of Java's general structure, and an extended discussion of cloning and equivalence testing in the context of data structures. • A new chapter on recursion provides a wide range of material that was previously divided into chapters 3, 4 and 9 of the fifth edition, while the newUse of recursion in file processing systems. Â »We offer a new empirical study on the effectiveness of Java Stringbuilder in connection with the Rechain chain and then discuss the theoretical foundations of its amortized performance. ¢ We offer an improved discussion about the Weers, which contrast between so -called lazy iterators and pictures and use examples for both relationships of several data structures. Â »We have increased the use of abstract class classes to reduce the discharge and provided several interface and nesting classes to ensure stronger encapsulation of our data structures. ¢ We have recorded the complete introduction of a mortar for many data structures and algorithms, which were only described in previous editions by pseudocode. These new implementations include field lines on the basis of field lines as well as a linked list, adaptable priorities, which are at bunch, stacking structure from bottom to top, hash tables with a separate chain or a linear probe, spray trees, dynamic programming, smaller data structure are based on unification with travel exploits, first schedule search, Floyd -warshall -Algorithm to calculate the completion of the transient diagram, the topological sorting of DAG as primary -Jarnā` ± k- and Krukal algorithms for minimal wood calculation. At www.it-box.info VI, we go from the main structure, including: ¢ variable and expressions that are referred to as functions or procedures) the structure of the decision (allegedly position and switched) ¢ Itsection structure) (iterative structure) (for -Lop and While) readers who know these concepts, but not with we offer a primer in Java 1 in the way they are developed in Java. This book is still mainly data book structures, not Java; Therefore, it does not provide comprehensive Java treatment. However, we do not believe that the reader is definitely known for his oriented design or interconnected structures such as lists, how these topics are included in the main chapters of this book. When it comes to the mathematical background, we assume that the reader is a small family with mathematics of high school.In Chapter 4 we therefore discuss the seven most important functions of the analysis of algorithms. In fact, sections that use something else, with the exception of one of these seven functions, are considered optional and through a star (â). Online resources of this book are accompanied by a comprehensive series of online resources that can be found on the next website: www.wiley.com/college/goodrich on this page is a number of educational instruments that increase the topics of this book concerns students and for instructors. For all readers and especially for students, we take into account the following resources: "The entire Java source code, which was presented in this book" Useful Mathematical Facts PDF- PDF-PowerPoint sequence "(four on the page), to the leading principles of exercises defined by the problem of problematic instructors using this book. We take into account the following additional educational instruments: • Solutions for hundreds of book exercises - The colors of all numbers and illustrations from the book - in PowerPoint and PDF (one page) of the foils are completely edited so that the trainer enables the trainer so that the trainer can use the use An instructor used who is full of free house to adapt his presentation. www.it-books.info foreword VII-attachment as a design of a textbook and the analysis of effective data structures has long been considered the main topic in calculations. We believe that the central role of design and the analysis of the data structure in the curriculum is fully justified, whereby the importance of effective structures and algorithms of data in most software systems, including networks, operating systems, databases, compilers and scientific modeling, this book is for the use in the course data structures at the start level or in the introduction of algorithms. The chapters of this book are organized to ensure the educational path, which begins with the reasons for the programming of Java and the design of objects. Then we will discuss certain structures, including tips and related letters and basic methods, such as: B. Analysis of algorithm and recursion. In the main part of the book we present the main data structures and algorithms and end with a discussion about memory management. The detailed content of the table corresponds to this foreword, starting with X.. An important unit of knowledgeAL/Basic Analysis Chapter 4 and Part 5.2 and 12.1.4 AL/Algorithmic Strategy Part 5.3.3, 12.1.1, 13.2.1, 13.4.2, 13.5, 14.6.2 and 14.7 AL/Basic Data Structures and Algorithms 3. .2, 5.1.3, 9.3, 9.4.1, 10.2, 11.1, 13.2 and chapters 12 and 14 Al/Advanced Data Structures, section 7.2.1, 10.4, 11.2 (11.6, 12.2.5, 3145 and 145. AR architecture /Memory System Chapter 15 DS/KIT, Relationships and Functions Section 9.2.2 and 10.5 DS/Proof Technology., 6.2.2, 8.2.2 9.5.1 and 11.2.1 SDF/Algorithms and Design Section 2.1, 4.3 and 12.1.1 SDF/Basic Programming Concepts Chapter 1 and 5 SDF/Basic Data Structure Chapters 3 and 6 Parts 1.3, 9.11 and SDF 10 Methods Part 1.9 and 2.4 Construction with/Software 2.1 Part 2.1 Mapping the IEEE/ACM 2013 Curriculum 2013 P for P for P Leaving the messages in this book www.it-ebooks.info viii Foreword by the authors Michael Goodrich won a Ph.D. in Computer Science from Purdue University in 1987. He is currently a Chancellor Professor in the Computer Science Department at the University of California, Irvine. Previously, he was a professor at Johns Hopkins University. He is a Fulbright Scholar and a member of the American Association for the Advancement of Science (AAAS), the Association for Computer Machinery (ACM), and the Institute of Electrical and Electronics Engineers (IEEE). These are the IEEE Computer Society Technical Ageivement Award, the ACM Service Recognition, and the Pond Award for Excellence in College Education. Roberto Tamassia won the title of Ph.D. in electrical and computer engineering from the University of Illinois at Champaign Urbana in 1988. He is a professor of computer science and head of the computer science department at Brown University. He is also the director of the Browns Center for Geometric Computing. His research interests include information security, cryptography, analysis, algorithm design and implementation, drawing graphics, and computational geometry. He is a member of the American Association for the Advancement of Science (AAAS), the Association for Computer Machinery (ACM) and the Institute of Electrical and Electronic Engineers (IEEE). HeIEEE Computer Society Award. Michael Goldwasser won the Ph.D title. Computer science at Stanford University in 1997. He is currently a professor and director of the Department of Mathematics and Computer Science at the University of St. Louis. He was a lecturer at the University of Chicago Loyola University. His research interests are aimed at the development and implementation of algorithms, publications, including approximation algorithms, online computing, computing biology and computing geometry. He is also active in the computer science education community. Other books of these authors are di Battista, Eades, Tamassia and Tollis, Graphic Drawing, Prentice Hall - Goodrich, Tamassia and Goldwasser, data structures and algorithms in the language of Python, Wiley - Goodrich, Tamassia and Mount, data structures and algorithms in C ++. Wiley. ¢ Goodrich and Tamassia, Algorithm Design: Basics, Analysis and Internet Examples, Wiley ¢ Goodrich and Tamassia, Introduction to Computer Safety, Addison-Wesley- Goldwasser and Letscher, Object Oriented Python, Prentice Hall and Letscher oriented object oriented program Python, Prentice Hall, Prentice Hall, Prentice Hall. .Info Preface IX Thanks for their contribution to the development of this book over the last decade, it is difficult to list them all. We want to thank many researchers and teachers' assistants whose feedback has been made by previous versions of this material. The benefits of these investments are also transferred to this book. In the sixth edition, we are faithful to external reviewers and readers for their many comments, emails and constructive criticism. We would like to thank such people for comments and suggestions: Samir O. Abufarde (North Dakota University), Mary Boelka (Marquette University), Frederick Krab (United States Maritime Academy), Scott Drisdale (Dartmmt), David Eisner. Henry A. Etlinger (Institute of Rochester Technology), Chun Hsi Huang (University of Connecticut), John Laseter (Hobart and William Smith College), Jupen Lin, Sulia Oliveira (University of Iova), Vincent Van Osers (University of Innsbruck), Viktor I. Stern (University of Boston), Tim Soets and many other anonymous reviewers. There are several friends and colleagues whose comments have led to improvementsWe are especially grateful to Erin Chambers, Karen Gudrich, David Poyg, David Mount, and Ioannis Tollis for their penetrating comments. Also, David Mount's contribution to the recursion shell and some numbers should be gratefully noted. Thanks to Wiley's wonderful team, including our editor Bet Lang Golub for their passionate support of this project from start to finish, and Solutions group editors Mary Sullivan and Ellen Kehein for completing the project. The quality of this book has greatly improved due to the attention to detail shown by our scribber Julie Kennedy. Joyce Fuck elegantly guided the final months of the production process. Finally, we would like to sincerely thank Karen Gudrich, Isabelle Cruz, Susan Goldvasser, Giuseppe di Battista, Franco from Drug, John Tollis and our parents for their advice, support and support throughout the various stages of the work on this book. And to Kalista and Maya Goldvasser for advice on the artistic merits of many illustrations. More importantly, we thank all these people for reminding us that there are other things in life besides writing books. Michael T. Gudrich Roberto Tamassia Michael H. Goldvasser www.it-ebooks.info content 1 Java starter 1 1.1 start of work. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.1.1 Types of bases. . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.2 Classes and objects. . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.2.1 Creating and using objects. . . . . . . . . . . . . . . . . . . . 6 1.2.2 Class definition. . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.3 Lines, shells, arrays and types listed. . . . . . . . . . . . . 17 1.4 Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 1.4.1 literals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 1.4.2 Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 1.4.3 Type transformation. . . . . . . . . . . . . . . . . . . . . . . . . 28 1.5 Stream Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 1.5.1 If and switch teams. . . . . . . . . . . . . . . . . . 30 1.5.2 Cycles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 1.5.3 Control Flow Operators. . . . . . . . . . . . . . . . . 37 1.6 Simple input and conclusions. . . . . . . . . . . . . . . . . . . . . . . .1.7 Program example. . . . . . . . . . . . . . . . . . . . . . . . . . 41 1.8 Packages and imports . . . . . . . . . . . . . . . . . . . . . . . . . . 44 1.9 Software Development . . . . . . . . . . . . . . . . . . . . . . . . . 46 1.9.1 Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 1.9.2 Pseudocode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 1.9.3 Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 1.9.4 Documentation and design . . . . . . . . . . . . . . . . . . . . . 50 1.9.5 Testing and debugging . . . . . . . . . . . . . . . . . . . . . . 53 1.10 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 2 Object-Oriented Design 59 2.1 Goals, Principles, and Patterns . . . . . . . . . . . . . . . . . . . . 60 2.1.1 Goals of object-oriented design . . . . . . . . . . . . . . . . . . 60 2.1.2 Principles of object-oriented design . . . . . . . . . . . . . . . . 61 2.1.3 Design patterns . . . . . . . . . . . . . . . . . . . . . . . . . . 63 2.2 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 2.2.1 Extending the class of credit cards. . . . . . . . . . . . . . . . . . 65 2.2.2 Polymorphism and dynamic scheduling. . . . . . . . . . . . . . 68 2.2.3 Inheritance hierarchy . . . . . . . . . . . . . . . . . . . . . . 69 2.3 Interfaces and abstract classes. . . . . . . . . . . . . . . . . . . . 76 2.3.1 Interface in Java. . . . . . . . . . . . . . . . . . . . . . . . . 76 2.3.2 Multiple inheritance for interfaces. . . . . . . . . . . . . . . . 79 2.3.3 Abstract classes . . . . . . . . . . . . . . . . . . . . . . . . . . 80 2.4 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 2.4.1 Exception detection . . . . . . . . . . . . . . . . . . . . . . . . 82 2.4.2 Throwing exceptions . . . . . . . . . . . . . . . . . . . . . . . 85 2.4.3 Java Exception Hierarchy . . . . . . . . . . . . . . . . . . . . 86 2.5 Casting and generics . . . . . . . . . . . . . . . . . . . . . . . . . . 88 x www.it-ebooks.info content xi 2.5.1 Casting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 2.5.2 General provisions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 2.6 Nested classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 2.7 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 3 Basic data structures 103 3.1 Using fields . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . 104 3.1.1. Storage of gaming records in the mass. . . . . . . . . . . . . . . . . 104 3.1.2 Sorting an array. . . . . . . . . . . . . . . . . . . . . . . . . . 110 3.1.3 Java.util methods for arrays and random numbers. . . . . . . 112 3.1.4 Simple Cryptography with Symbol Arrays. . . . . . . . . . . 115 3.1.5 Two-dimensional massifs and positional games. . . . . . . . . 118 3.2. Individually related lists. . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 3.2.1. Implementation of the class of a single leaf list. . . . . . . . . . . . . 126 3.3. Circular Related Lists. . . . . . . . . . . . . . . . . . . . . . . . . . 128 3.3.1. circuit planning. . . . . . . . . . . . . . . . . . . . . 128 3.3.2. Creation and implementation of a cyclically related list. . . . . . 129 3.4. Duplicate Lists. . . . . . . . . . . . . . . . . . . . . . . . . . . 132 3.4.1. Implementation of the double list class. . . . . . . . . . . . 135 3.5. Equivalent test. . . . . . . . . . . . . . . . . . . . . . . . . . . 138 3.5.1. Check equivalence with arrays. . . . . . . . . . . . . . . . . 139 3.5.2. Check equivalence with bound lists. . . . . . . . . . . . . . 140 3.6. clone data structures. . . . . . . . . . . . . . . . . . . . . . . . 141 3.6.1. Cloning arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . 142 3.6.2 Cloning related lists. . . . . . . . . . . . . . . . . . . . . . . . 144 3.7. exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 4 Analysis of the Algorithms 149 4.1. Experimental Research. . . . . . . . . . . . . . . . . . . . . . . . . . 151 4.1.1. Finish beyond experimental analysis. . . . . . . . . . . . . . 154 4.2. Seven functions used in this book. . . . . . . . . . . . . . . 156 4.2.1. Comparison of growth rates. . . . . . . . . . . . . . . . . . . . . 163 4.3 Asymptotic Analysis. . . . . . . . . . . . . . . . . . . . . . . . . . . 164 4.3.1. The designation "Big Okha". . . . . . . . . . . . . . . . . . . . . . 164 4.3.2. Comparative Analysis. . . . . . . . . . . . . . . . . . . . . . . 168 4.3.3. Algorithm analysis examples. . . . . . . . . . . . . . . . . 170 4.4. Simple methods of argument. . . . . . . . . . . . . . . . . . . . 178 4.4.1 with an example. . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 4.4.2. Reaction employee attack. . . . . . . . . . . . . . . . . . . . . . . 178 4.4.3. Induction and invariants of loops. . . . . . . . . . . . . . . . . . 179 4.5 Exercises. . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . 182 5 Recursion 189 5.1. Illustrative examples. . . . . . . . . . . . . . . . . . . . . . . . . . 191 5.1.1. Factor function. . . . . . . . . . . . . . . . . . . . . . 191 5.1.2 Drawing an English ruler . . . . . . . . . . . . . . . . . . . . . 193 5.1.3 Binary search . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 www.it-ebooks.info xii Contents 5.1.4 File Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 5.2. Analysis of recursive algorithms. . . . . . . . . . . . . . . . . . . . 202 5.3 Other examples of recursion . . . . . . . . . . . . . . . . . . . . . 206 5.3.1 Linear Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . 206 5.3.2 Binary Recursion . . . . . . . . . . . . . . . . . . . . . . . . . 211 5.3.3 Multiple Recursion . . . . . . . . . . . . . . . . . . . . . . . . 212 5.4. Development of recursive algorithms. . . . . . . . . . . . . . . . . . . . 214 5.5. Recursion gone mad. . . . . . . . . . . . . . . . . . . . . . . . . . 215 5.5.1 Maximum depth of recursion in Java . . . . . . . . . . . . . . . . 218 5.6. Prevention of tail recursion. . . . . . . . . . . . . . . . . . . . . . . 219 5.7. Exercise. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 6 Stocks, queues and queues 225 6.1 Stocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 6.1.1. Stack abstract data type. . . . . . . . . . . . . . . . . . 227 6.1.2. A simple stack implementation based on arrays. . . . . . . . . . 230 6.1.3. Stack implementation with simply linked lists. . . . . . . . . 233 6.1.4. Cropping an array using stack . . . . . . . . . . . . . . . . 234 6.1.5 Pairing brackets and HTML tags . . . . . . . . . . . . . 235 6.2 Tails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 6.2.1. Abstract data type Queue . . . . . . . . . . . . . . . . . 239 6.2.2. Implementation of an array-based queue. . . . . . . . . . . . . . . 241 6.2.3. A separately linked list queue implementation. . . . . . . . . 245 6.2.4 Round robin . . . . . . . . . . . . . . . . . . . . . . . . . 246 6.3 Bidirectional Queues . . . . . . . . . . . . . . . . . . . . . . . . . . 248 6.3.1. Abstract data type rejection. . . . . . . . . . . . . . . . . 248 6.3.2 Deque Implementation . . . . . . . . . . . . . . . . . . . . . . 250 6.3.3. Deques in the Java Collections Framework. . . . . . . . . . . . 251 6.4 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 252 7 LIST AND ITERATOR ADS 257 7.1 LIST ADS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 7.2. Field lists. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 7.2.1. Dynamic fields. . . . . . . . . . . . . . . . . . . . . . . . . . 263 7.2.2 Dynamic field implementation. . . . . . . . . . . . . . . . . . 264 7.2.3. Damped analysis of dynamic fields. . . . . . . . . . . . . . 265 7.2.4 Java class with StringBuilder. . . . . . . . . . . . . . . . . . . . . 269 7.3 Position Listings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 7.3.1 Location. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 7.3.2 Abstract data type position. . . . . . . . . . . . . 272 7.3.3 Doubly Linked List Implementation . . . . . . . . . . . . . . . . 276 7.4 Iterators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 7.4.1. Iterable internals and the Java for-each loop. . . . . . . . 283 7.4.2. Iterators introduced. . . . . . . . . . . . . . . . . . . . . . 284 7.5 Java collection. . . . . . . . . . . . . . . . . . . 288 7.5.1 List of Java iterators. . . . . . . . . . . . . . . . . . . . . . . 289 7.5.2. Comparison with our position list in ADT. . . . . . . . . . . . . 290 www.it-ebooks.info Contents xiii 7.5.3 Algorithms based on Java collection. . . . 291 7.6 Sorting the list of positions. . . . . . . . . . . . . . . . . . . . . . . . 293 7.7. Case Study: Maintenance of Access Frequencies. . . . . . . . . . . . 294 7.7.1 Using an ordered list. . . . . . . . . . . . . . . . . . . . . . . . 294 7.7.2. Using a forward heuristic list. . . . . . . . . . 297 7.8. task. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 8 Trees 307 8.1 General Trees. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 8.1.1. Definition and characteristics of trees. . . . . . . . . . . . . . . . . . 309 8.1.2. Summary Tree data type. . . . . . . . . . . . . . . . . . 312 8.1.3. Depth and height are calculated. . . . . . . . . . . . . . . . . . . 314 8.2. Binary trees. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 8.2.1. Summary Binary tree data type. . . . . . . . . . . . . . . 319 8.2.2. Properties of binary trees. . . . . . . . . . . . . . . . . . . . 321 8.3. Implementation of the tree. . . . . . . . . . . . . . . . . . . . . . . . . . . 323 8.3.1 A connected structure for binary trees. . . . . . . . . . . . . . .Addendum 323 8.3.2. An arch based on a board. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 331 8.3.3. The associated general tree structure. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 333 8.4 Wood Detour Algorithms. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 334 8.4 8.4 Appuse Appuse Appuse Appuse Appuse 334 8.4.2. First pass through the tree. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 336 8.4.3. Binary wood inclusion. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 337 8.4.4. Implementing Tree Bypass in Java. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 339 8.4.5 wood bypass. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 343 8.4.6. Ender tours. Appise Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appaze Appee Appe Appe Appuse Appuse Appuse Appuse Appuse Appus Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 350 9 Приоритетные очереди 359 9.1. Abstract of the queue's priority data type. Appise Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 360 9.1.1.1 Priorities. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 360 9.1.2. ADT Priority Queue. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 361 9.2. Implementation of the priority queue. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 362 9.2.1. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 362 9.2.2.2.2.2.2. Compare the keys with the total number of orders. Appise Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 363 9.2.3. The base class abstractionPriorityqueue. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 364 9.2.4. Implementation of a priority queue with an unsorted list. Appuse Appuse Appuse Appuse Appuse 9.2.5. Implementation of a priority queue with an ordered list. Appuse Appuse Appuse Appuse Appuse Appuse 368 9.3 stacks. 9.3.1 Structure of these stacks. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 370 9.3.2. Implementation of a priority queue with a group. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 372 9.3.3. Analysis of the priority queue in the heap. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 379 9.3.4. Top Pile Design â. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 380 9.3.5. Using the java.util.priorityqueue class. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 384 9.4 Sort with Priority. Appise Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 385 9.4.1 Select SORT and SSROTION- SOSORTORTION Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 386 9.4.2 SHEAP-SORT. Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse Appuse 388 www.it-ebooks.infose more
no reviews yet
Please Login to review.