logo资料库

Data Structures & Algorithms in Java Second Edition amazon.pdf

第1页 / 共770页
第2页 / 共770页
第3页 / 共770页
第4页 / 共770页
第5页 / 共770页
第6页 / 共770页
第7页 / 共770页
第8页 / 共770页
资料共770页,剩余部分请下载后查看
Cover Page
Title Page
Copyright Page
Dedication
Contents
1 OBJECT-ORIENTED PROGRAMMING USING JAVA
1.1 Rudimentary Java
1.1.1 Variable Declarations
1.1.2 Operators
1.1.3 Decision Statements
1.1.4 Loops
1.1.5 Exception Handling
1.2 Object-Oriented Programming in Java
1.2.1 Encapsulation
1.2.2 Abstract Data Types
1.2.3 Inheritance
1.2.4 Polymorphism
1.3 Input and Output
1.3.1 Reading and Writing Bytes
1.3.2 Reading Lines
1.3.3 Reading Tokens: Words and Numbers
1.3.4 Reading and Writing Primitive Data Types
1.3.5 Reading and Writing Objects
1.3.6 Random Access File
1.4 Java and Pointers
1.5 Vectors in java.util
1.6 Data Structures and Object-Oriented Programming
1.7 Case Study: Random Access File
1.8 Exercises
1.9 Programming Assignments
Bibliography
2 COMPLEXITY ANALYSIS
2.1 Computational and Asymptotic Complexity
2.2 Big-O Notation
2.3 Properties of Big-O Notation
2.4 Ω and Θ Notations
2.5 Possible Problems
2.6 Examples of Complexities
2.7 Finding Asymptotic Complexity: Examples
2.8 The Best, Average, and Worst Cases
2.9 Amortized Complexity
2.10 NP-Completeness
2.11 Exercises
Bibliography
3 LINKED LISTS
3.1 Singly Linked Lists
3.1.1 Insertion
3.1.2 Deletion
3.1.3 Search
3.2 Doubly Linked Lists
3.3 Circular Lists
3.4 Skip Lists
3.5 Self-Organizing Lists
3.6 Sparse Tables
3.7 Lists in java.util
3.7.1 LinkedList
3.7.2 ArrayList
3.8 Concluding Remarks
3.9 Case Study: A Library
3.10 Exercises
3.11 Programming Assignments
Bibliography
4 STACKS AND QUEUES
4.1 Stacks
4.1.1 Stacks in java.util
4.2 Queues
4.3 Priority Queues
4.4 Case Study: Exiting a Maze
4.5 Exercises
4.6 Programming Assignments
Bibliography
5 RECURSION
5.1 Recursive Definitions
5.2 Method Calls and Recursion Implementation
5.3 Anatomy of a Recursive Call
5.4 Tail Recursion
5.5 Nontail Recursion
5.6 Indirect Recursion
5.7 Nested Recursion
5.8 Excessive Recursion
5.9 Backtracking
5.10 Concluding Remarks
5.11 Case Study: A Recursive Descent Interpreter
5.12 Exercises
5.13 Programming Assignments
Bibliography
6 BINARY TREES
6.1 Trees, Binary Trees, and Binary Search Trees
6.2 Implementing Binary Trees
6.3 Searching a Binary Search Tree
6.4 Tree Traversal
6.4.1 Breadth-First Traversal
6.4.2 Depth-First Traversal
6.4.3 Stackless Depth-First Traversal
6.5 Insertion
6.6 Deletion
6.6.1 Deletion by Merging
6.6.2 Deletion by Copying
6.7 Balancing a Tree
6.7.1 The DSW Algorithm
6.7.2 AVL Trees
6.8 Self-Adjusting Trees
6.8.1 Self-Restructuring Trees
6.8.2 Splaying
6.9 Heaps
6.9.1 Heaps as Priority Queues
6.9.2 Organizing Arrays as Heaps
6.10 Polish Notation and Expression Trees
6.10.1 Operations on Expression Trees
6.11 Case Study: Computing Word Frequencies
6.12 Exercises
6.13 Programming Assignments
Bibliography
7 MULTIWAY TREES
7.1 The Family of B-Trees
7.1.1 B-Trees
7.1.2 B*-Trees
7.1.3 B+-Trees
7.1.4 Prefix B+-Trees
7.1.5 Bit-Trees
7.1.6 R-Trees
7.1.7 2–4 Trees
7.1.8 Trees in java.util
7.2 Tries
7.3 Concluding Remarks
7.4 Case Study: Spell Checker
7.5 Exercises
7.6 Programming Assignments
Bibliography
8 GRAPHS
8.1 Graph Representation
8.2 Graph Traversals
8.3 Shortest Paths
8.3.1 All-to-All Shortest Path Problem
8.4 Cycle Detection
8.4.1 Union-Find Problem
8.5 Spanning Trees
8.6 Connectivity
8.6.1 Connectivity in Undirected Graphs
8.6.2 Connectivity in Directed Graphs
8.7 Topological Sort
8.8 Networks
8.8.1 Maximum Flows
8.8.2 Maximum Flows of Minimum Cost
8.9 Matching
8.9.1 Stable Matching Problem
8.9.2 Assignment Problem
8.9.3 Matching in Nonbipartite Graphs
8.10 Eulerian and Hamiltonian Graphs
8.10.1 Eulerian Graphs
8.10.2 Hamiltonian Graphs
8.11 Graph Coloring
8.12 NP-Complete Problems in Graph Theory
8.12.1 The Clique Problem
8.12.2 The 3-Colorability Problem
8.12.3 The Vertex Cover Problem
8.12.4 The Hamiltonian Cycle Problem
8.13 Case Study: Distinct Representatives
8.14 Exercises
8.15 Programming Assignments
Bibliography
9 SORTING
9.1 Elementary Sorting Algorithms
9.1.1 Insertion Sort
9.1.2 Selection Sort
9.1.3 Bubble Sort
9.2 Decision Trees
9.3 Efficient Sorting Algorithms
9.3.1 Shell Sort
9.3.2 Heap Sort
9.3.3 Quicksort
9.3.4 Mergesort
9.3.5 Radix Sort
9.4 Sorting in java.util
9.5 Concluding Remarks
9.6 Case Study: Adding Polynomials
9.7 Exercises
9.8 Programming Assignments
Bibliography
10 HASHING
10.1 Hash Functions
10.1.1 Division
10.1.2 Folding
10.1.3 Mid-Square Function
10.1.4 Extraction
10.1.5 Radix Transformation
10.2 Collision Resolution
10.2.1 Open Addressing
10.2.2 Chaining
10.2.3 Bucket Addressing
10.3 Deletion
10.4 Perfect Hash Functions
10.4.1 Cichelli’s Method
10.4.2 The FHCD Algorithm
10.5 Hash Functions for Extendible Files
10.5.1 Extendible Hashing
10.5.2 Linear Hashing
10.6 Hashing in java.util
10.6.1 HashMap
10.6.2 HashSet
10.6.3 HashTable
10.7 Case Study: Hashing with Buckets
10.8 Exercises
10.9 Programming Assignments
Bibliography
11 DATA COMPRESSION
11.1 Conditions for Data Compression
11.2 Huffman Coding
11.2.1 Adaptive Huffman Coding
11.3 Run-Length Encoding
11.4 Ziv-Lempel Code
11.5 Case Study: Huffman Method with Run-Length Encoding
11.6 Exercises
11.7 Programming Assignments
Bibliography
12 MEMORY MANAGEMENT
12.1 The Sequential-Fit Methods
12.2 The Nonsequential-Fit Methods
12.2.1 Buddy Systems
12.3 Garbage Collection
12.3.1 Mark-and-Sweep
12.3.2 Copying Methods
12.3.3 Incremental Garbage Collection
12.4 Concluding Remarks
12.5 Case Study: An In-Place Garbage Collector
12.6 Exercises
12.7 Programming Assignments
Bibliography
13 STRING MATCHING
13.1 Exact String Matching
13.1.1 Straightforward Algorithms
13.1.2 The Knuth-Morris-Pratt Algorithm
13.1.3 The Boyer-Moore Algorithm
13.1.4 Multiple Searches
13.1.5 Bit-Oriented Approach
13.1.6 Matching Sets of Words
13.1.7 Regular Expression Matching
13.1.8 Suffix Tries and Trees
13.1.9 Suffix Arrays
13.2 Approximate String Matching
13.2.1 String Similarity
13.2.2 String Matching with k Errors
13.3 Case Study: Longest Common Substring
13.4 Exercises
13.5 Programming Assignments
Bibliography
APPENDIXES
A Computing Big-O
A.1 Harmonic Series
A.2 Approximation of the Function lg(n!)
A.3 Big-O for Average Case of Quicksort
A.4 Average Path Length in a Random Binary Tree
A.5 The Number of Nodes in an AVL Tree
B NP-Completeness
B.1 Cook’s Theorem
Name Index
Subject Index
Data Structures and Algorithms in Java SECOND EDITION Adam Drozdek Australia • Canada • Mexico • Singapore • Spain • United Kingdom • United States Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Data Structures and Algorithms in Java SECOND EDITION Adam Drozdek Australia • Canada • Mexico • Singapore • Spain • United Kingdom • United States
Data Structures and Algorithms in Java SECOND EDITION Adam Drozdek Australia • Canada • Mexico • Singapore • Spain • United Kingdom • United States Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Data Structures and Algorithms in Java, Second Edition by Adam Drozdek Senior Acquisitions Editor: Amy Yarnevich Product Manager: Alyssa Pratt Editorial Assistant: Amanda Piantedosi Senior Marketing Manager: Karen Sietz Production Editor: Jennifer Harvey Associate Product Manager: Mirella Misiaszek Cover Design: Joel Sadagursky Compositor: Pre-Press Company, Inc. COPYRIGHT © 2005 Course Technology, a division of Thomson Learning, Inc. Thomson Learning™ is a trademark used herein under license. Printed in the United States of America 1 2 3 4 5 6 7 8 9 BM 06 05 04 03 02 For more information, contact Course Technology, 25 Thomson Place, Boston, Massachusetts, 02210. Or find us on the World Wide Web at: www.course.com ALL RIGHTS RESERVED. No part of this work covered by the copyright hereon may be reproduced or used in any form or by any means—graphic, electronic, or mechanical, including photocopying, recording, taping, Web distribution, or information storage and retrieval systems—without the written permission of the publisher. For permission to use material from this text or product, contact us by (800) 730-2214 Tel Fax (800) 730-2215 www.thomsonrights.com Disclaimer Course Technology reserves the right to revise this publication and make changes from time to time in its content without notice. ISBN 0-534-49252-5 Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
TO MY WIFE, BOGNA Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
Contents 1 OBJECT-ORIENTED PROGRAMMING USING JAVA 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 6 8 18 27 26 1 4 1 5 6 16 Rudimentary Java 1.1.1 Variable Declarations 1.1.2 Operators 1.1.3 Decision Statements 1.1.4 Loops 1.1.5 Exception Handling Object-Oriented Programming in Java 1.2.1 Encapsulation 8 1.2.2 Abstract Data Types 1.2.3 Inheritance 1.2.4 Polymorphism 21 Input and Output 24 1.3.1 Reading and Writing Bytes 1.3.2 Reading Lines 1.3.3 Reading Tokens: Words and Numbers 1.3.4 Reading and Writing Primitive Data Types 1.3.5 Reading and Writing Objects 1.3.6 Random Access File Java and Pointers 31 Vectors in java.util Data Structures and Object-Oriented Programming Case Study: Random Access File Exercises Programming Assignments Bibliography 35 42 53 55 28 29 29 30 51 42 Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
vi ■ C o n t e n t s 2 COMPLEXITY ANALYSIS 59 57 61 62 Computational and Asymptotic Complexity Big-O Notation Properties of Big-O Notation Ω and Q Notations Possible Problems Examples of Complexities Finding Asymptotic Complexity: Examples The Best, Average, and Worst Cases Amortized Complexity 73 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 NP-Completeness 2.11 62 66 69 Exercises Bibliography 76 79 3 LINKED LISTS 56 64 56 80 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 93 101 Singly Linked Lists 86 3.1.1 Insertion 3.1.2 Deletion 88 3.1.3 Search Doubly Linked Lists Circular Lists 99 Skip Lists Self-Organizing Lists Sparse Tables 111 Lists in java.util 3.7.1 LinkedList 3.7.2 ArrayList Concluding Remarks Case Study: A Library Exercises Programming Assignments Bibliography 134 139 114 120 80 95 107 114 123 124 136 Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part.
分享到:
收藏