Data Structures and Other Objects Using Java 4th Edition by Michael Main, ISBN-13: 978-0132576246
[PDF eBook eTextbook]
- Publisher: Pearson; 4th edition (November 2, 2011)
- Language: English
- 856 pages
- ISBN-10: 0132576244
- ISBN-13: 978-0132576246
Data Structures and Other Objects Using Java is a gradual, “just-in-time” introduction to Data Structures for a CS2 course.
Table of Contents:
Data Structures & Other Objects: Using Java™
Preface
New to the Fourth Edition
Where Will the Students Be at the End of the Course?
Other Foundational Topics
Advanced Projects, Including Concurrency
Java Language Versions
Flexibility of Topic Ordering
Chapter Dependencies
Supplements Via the Internet
Acknowledgments
Chapter 1 The Phases of Software Development
Learning Objectives
Chapter Contents
What You Should Know About Java Before Starting This Text
1.1 Specification, Design, Implementation
Design Technique: Decomposing the Problem
How to Write a Specification for a Java Method
Temperature Conversion: Implementation
Self-Test Exercises for Section 1.1
1.2 Running Time Analysis
The Stair-Counting Problem
Big-O Notation
Time Analysis of Java Methods
Worst-Case, Average-Case, and Best-Case Analyses
Self-Test Exercises for Section 1.2
1.3 Testing and Debugging
Choosing Test Data
Boundary Values
Fully Exercising Code
Using a Debugger
Assert Statements
Turning Assert Statements On and Off
Static Checking Tools
Self-Test Exercises for Section 1.3
Chapter Summary
Solutions to Self-Test Exercises
Chapter 2 Java Classes and Information Hiding
Learning Objectives
Chapter Contents
2.1 Classes and Their Members
Defining a New Class
Instance Variables
Constructors
No-Arguments Constructors
Methods
Accessor Methods
Modification Methods
Complete Definition of Throttle.java
Methods May Activate Other Methods
Self-Test Exercises for Section 2.1
2.2 Using a Class
Creating and Using Objects
A Program with Several Throttle Objects
Null References
Assignment Statements with Reference Variables
Clones
Testing for Equality
Terminology Controversy: “The Throttle That t Refers To”
Self-Test Exercises for Section 2.2
2.3 Packages
Declaring a Package
The Import Statement to Use a Package
The JCL Packages
More about Public, Private, and Package Access
Self-Test Exercises for Section 2.3
2.4 Parameters, Equals Methods, and Clones
The Location Class
Static Methods
Parameters That Are Objects
Methods May Access Private Instance Variables of Objects in Their Own Class
The Return Value of a Method May Be an Object
Java’s Object Type
Using and Implementing an equals Method
Every Class Has an equals Method
Using and Implementing a clone Method
A Demonstration Program for the Location Class
What Happens When a Parameter Is Changed Within a Method?
Self-Test Exercises for Section 2.4
2.5 The Java Class Libraries
Chapter Summary
Solutions to Self-Test Exercises
Programming Projects
Chapter 3 Collection Classes
Learning Objectives
Chapter Contents
3.1 A Review Of Java Arrays
The Length of an Array
Assignment Statements with Arrays
Clones of Arrays
The Arrays Utility Class
Array Parameters
Self-Test Exercises for Section 3.1
3.2 An ADT For a Bag Of Integers
The Bag ADT—Specification
OutOfMemoryError and Other Limitations for Collection Classes
The IntArrayBag Class—Specification
The IntArrayBag Class—Demonstration Program
The IntArrayBag Class—Design
The Invariant of an ADT
The IntArrayBag ADT—Implementation
The Bag ADT—Putting the Pieces Together
The Bag ADT—Testing
The Bag ADT—Analysis
Self-Test Exercises for Section 3.2
3.3 Programming Project: The Sequence ADT
The Sequence ADT—Specification
The Sequence ADT—Documentation
The Sequence ADT—Design
The Sequence ADT—Pseudocode for the Implementation
Self-Test Exercises for Section 3.3
3.4 Programming Project: The Polynomial
Self-Test Exercises for Section 3.4
3.5 The Java Hashset And Iterators
The HashSet Class
Some of the HashSet Members
Iterators
Invalid Iterators
Self-Test Exercises for Section 3.5
Chapter Summary
Solutions to Self-Test Exercises
Programming Projects
Chapter 4 Linked Lists
Learning Objectives
Chapter Contents
4.1 Fundamentals Of Linked Lists
Declaring a Class for Nodes
Head Nodes, Tail Nodes
The Null Reference
Self-Test Exercises for Section 4.1
4.2 Methods For Manipulating Nodes
Constructor for the Node Class
Getting and Setting the Data and Link of a Node
Public Versus Private Instance Variables
Adding a New Node at the Head of a Linked List
Removing a Node from the Head of a Linked List
Adding a New Node That Is Not at the Head
Removing a Node That Is Not at the Head
Self-Test Exercises for Section 4.2
4.3 Manipulating an Entire Linked List
Computing the Length of a Linked List
Searching for an Element in a Linked List
Finding a Node by Its Position in a Linked List
Copying a Linked List
A Second Copy Method, Returning Both Head and Tail References
Copying Part of a Linked List
Using Linked Lists
Self-Test Exercises for Section 4.3
4.4 The Bag ADT With a Linked List
Our Second Bag—Specification
The grab Method
Our Second Bag—Class Declaration
The Second Bag—Implementation
The Second Bag—Putting the Pieces Together
Self-Test Exercises for Section 4.4
4.5 Programming Project: The Sequence ADT With a Linked List
The Revised Sequence ADT—Design Suggestions
The Revised Sequence ADT—Clone Method
Self-Test Exercises for Section 4.5
4.6 Beyond Simple Linked Lists
Arrays Versus Linked Lists and Doubly Linked Lists
Dummy Nodes
Java’s List Classes
ListIterators
Making the Decision
Self-Test Exercises for Section 4.6
Chapter Summary
Solutions to Self-Test Exercises
Programming Projects
Chapter 5 Generic Programming
Learning Objectives
Chapter Contents
5.1 Java’s Object Type and Wrapper Classes
Widening Conversions
Narrowing Conversions
Wrapper Classes
Autoboxing and Auto-Unboxing Conversions
Advantages and Disadvantages of Wrapper Objects
Self-Test Exercises for Section 5.1
5.2 Object Methods and Generic Methods
Object Methods
Generic Methods
Self-Test Exercises for Section 5.2
5.3 Generic Classes
Writing a Generic Class
Using a Generic Class
Details for Implementing a Generic Class
Creating an Array to Hold Elements of the Unknown Type
Retrieving E Objects from the Array
Warnings in Generic Code
Using ArrayBag as the Type of a Parameter or Return Value
Counting the Occurrences of an Object
The Collection Is Really a Collection of References to Objects
Set Unused References to Null
Steps for Converting a Collection Class to a Generic Class
Deep Clones for Collection Classes
Using the Bag of Objects
Details of the Story-Writing Program
Self-Test Exercises for Section 5.3
5.4 Generic Nodes
Nodes That Contain Object Data
Other Collections That Use Linked Lists
Self-Test Exercises for Section 5.4
5.5 Interfaces and Iterators
Interfaces
Generic Interfaces and the Iterable Interface
How to Write a Generic Class That Implements a Generic Interface
The Lister Class
The Comparable Generic Interface
Parameters That Use Interfaces
Using instanceof to Test Whether a Class Implements an Interface
The Cloneable Interface
Self-Test Exercises for Section 5.5
5.6 A Generic Bag Class That Implements the Iterable Interface (Optional Section)
Implementing a Bag of Objects Using a Linked List and an Iterator
Summary of the Four Bag Implementations
Self-Test Exercises for Section 5.6
5.7 The Java Collection Interface and Map Interface (Optional Section)
The Collection Interface
The Map Interface and the TreeMap Class
The TreeMap Class
The Word Counting Program
Self-Test Exercises for Section 5.7
Chapter Summary
Solutions to Self-Test Exercises
Programming Projects
Chapter 6 Stacks
Learning Objectives
Chapter Contents
6.1 Introduction to Stacks
The Stack Class—Specification
We Will Implement a Generic Stack
Programming Example: Reversing a Word
Self-Test Exercises for Section 6.1
6.2 Stack Applications
Programming Example: Balanced Parentheses
Evaluating Arithmetic Expressions
Evaluating Arithmetic Expressions—Specification
Evaluating Arithmetic Expressions—Design
Implementation of the evaluate Method
Evaluating Arithmetic Expressions—Testing and Analysis
Evaluating Arithmetic Expressions—Enhancements
Self-Test Exercises for Section 6.2
6.3 Implementations of the Stack ADT
Array Implementation of a Stack
Linked List Implementation of a Stack
Discussion of the Linked List Implementation of the Stack
Self-Test Exercises for Section 6.3
6.4 More Complex Stack Applications
Evaluating Postfix Expressions
Translating Infix to Postfix Notation
Using Precedence Rules in the Infix Expression
Correctness of the Conversion from Infix to Postfix
Self-Test Exercises for Section 6.4
Chapter Summary
Solutions to Self-Test Exercises
Programming Projects
Chapter 7 Queues
Learning Objectives
Chapter Contents
7.1 Introduction to Queues
The Queue Class
Uses for Queues
Self-Test Exercises for Section 7.1
7.2 Queue Applications
Java Queues
Programming Example: Palindromes
Programming Example: Car Wash Simulation
Car Wash Simulation—Specification
Car Wash Simulation—Design
Car Wash Simulation—Implementing the Car Wash Classes
Car Wash Simulation—Implementing the Simulation Method
Self-Test Exercises for Section 7.2
7.3 Implementations of The Queue Class
Array Implementation of a Queue
Linked List Implementation of a Queue
Self-Test Exercises for Section 7.3
7.4 Deques and Priority Queues (Optional Section)
Double-Ended Queues
Priority Queues
Priority Queue ADT—Specification
Priority Queue Class—An Implementation That Uses an Ordinary Queue
Priority Queue ADT—A Direct Implementation
Java’s Priority Queue
Self-Test Exercises for Section 7.4
Chapter Summary
Solutions to Self-Test Exercises
Programming Projects
Chapter 8 Recursive Thinking
Learning Objectives
Chapter Contents
8.1 Recursive Methods
Tracing Recursive Calls
Programming Example: An Extension of writeVertical
A Closer Look at Recursion
General Form of a Successful Recursive Method
Self-Test Exercises for Section 8.1
8.2 Studies of Recursion: Fractals and Mazes
Programming Example: Generating Random Fractals
A Method for Generating Random Fractals—Specification
The Stopping Case for Generating a Random Fractal
Putting the Random Fractal Method in an Applet
Programming Example: Traversing a Maze
Traversing a Maze—Specification
Traversing a Maze—Design
Traversing a Maze—Implementation
The Recursive Pattern of Exhaustive Search with Backtracking
Programming Example: The Teddy Bear Game
Self-Test Exercises for Section 8.2
8.3 Reasoning about Recursion
How to Ensure That There Is No Infinite Recursion in the General Case
Inductive Reasoning about the Correctness of a Recursive Method
Self-Test Exercises for Section 8.3
Chapter Summary
Solutions to Self-Test Exercises
Programming Projects
Chapter 9 Trees
Learning Objectives
Chapter Contents
9.1 Introduction to Trees
Binary Trees
Binary Taxonomy Trees
More Than Two Children
Self-Test Exercises for Section 9.1
9.2 Tree Representations
Array Representation of Complete Binary Trees
Representing a Binary Tree with a Generic Class for Nodes
Self-Test Exercises for Section 9.2
9.3 A Class for Binary Tree Nodes
Programming Example: Animal Guessing
Animal-Guessing Program—Design and Implementation
Animal-Guessing Program—Improvements
Self-Test Exercises for Section 9.3
9.4 Tree Traversals
Traversals of Binary Trees
Printing a Tree with an Indentation to Show the Depth
BTNode, IntBTNode, and Other Classes
Self-Test Exercises for Section 9.4
9.5 Binary Search Trees
The Binary Search Tree Storage Rules
The Binary Search Tree Bag—Implementation of Some Simple Methods
Counting the Occurrences of an Element in a Binary Search Tree
Adding a New Element to a Binary Search Tree
Removing an Element from a Binary Search Tree
The addAll, addMany, and union Methods
Implementing addAll
Time Analysis and an Internal Iterator
Self-Test Exercises for Section 9.5
Chapter Summary
Solutions to Self-Test Exercises
Programming Projects
Chapter 10 Tree Projects
Learning Objectives
Chapter Contents
10.1 Heaps
The Heap Storage Rules
The Priority Queue Class with Heaps
Adding an Element to a Heap
Removing an Element from a Heap
Self-Test Exercises for Section 10.1
10.2 B-Trees
The Problem of Unbalanced Trees
The B-Tree Rules
An Example B-Tree
The Set Class with B-Trees
Searching for an Element in a B-Tree
Adding an Element to a B-Tree
The Loose Addition Operation for a B-Tree
A Private Method to Fix an Excess in a Child
Back to the add Method
Employing Top-Down Design
Removing an Element from a B-Tree
The Loose Removal from a B-Tree
A Private Method to Fix a Shortage in a Child
Removing the Biggest Element from a B-Tree
External B-Trees
Self-Test Exercises for Section 10.2
10.3 Java Support for Trees
The DefaultMutableTreeNode from javax.swing.tree
Using the JTree Class to Display a Tree in an Applet
The JApplet Class
What the TreeExample Applet Displays
Self-Test Exercises for Section 10.3
10.4 Trees, Logs, and Time Analysis
Time Analysis for Binary Search Trees
Time Analysis for Heaps
Logarithms
Logarithmic Algorithms
Self-Test Exercises for Section 10.4
Chapter Summary
Solutions to Self-Test Exercises
Programming Projects
Chapter 11 Searching
Learning Objectives
Chapter Contents
11.1 Serial Search and Binary Search
Serial Search
Serial Search—Analysis
Binary Search
Binary Search—Design
Binary Search—Analysis
Java’s Binary Search Methods
Self-Test Exercises for Section 11.1
11.2 Open-Address Hashing
Introduction to Hashing
Noninteger Keys and Java’s hashCode Method
The Table ADT—Specification
The Table ADT—Design
The Table ADT—Implementation
A Practical Illustration of Open-Address Hashing
Choosing a Hash Function to Reduce Collisions
Double Hashing to Reduce Clustering
Self-Test Exercises for Section 11.2
11.3 Using Java’s Hashtable Class
11.4 Chained Hashing
Self-Test Exercises for Section 11.4
11.5 Programming Project: A Table Class Implemented With Java’s Vector and Linkedlist
A New Table Class
Data Structures for the New Table Class
Implementing the New Table Class
Self-Test Exercises for Section 11.5
11.6 Time Analysis of Hashing
The Load Factor of a Hash Table
Self-Test Exercises for Section 11.6
Chapter Summary
Solutions to Self-Test Exercises
Programming Projects
Chapter 12 Sorting
Learning Objectives
Chapter Contents
12.1 Quadratic Sorting Algorithms
Selectionsort—Specification
Selectionsort—Design
Selectionsort—Testing
Selectionsort—Analysis
Insertionsort
Insertionsort—Analysis
Self-Test Exercises for Section 12.1
12.2 Recursive Sorting Algorithms
Divide-and-Conquer Using Recursion
Mergesort
The merge Function
Mergesort—Analysis
Mergesort for Files
Quicksort
The Partition Method
Quicksort—Analysis
Quicksort—Choosing a Good Pivot Element
Self-Test Exercises for Section 12.2
12.3 An O(N Log N) Algorithm Using a Heap
Heapsort
Making the Heap
Reheapification Downward
Heapsort—Analysis
Self-Test Exercise for Section 12.3
12.4 Java’s Sort Methods
Self-Test Exercises for Section 12.4
12.5 Concurrent Recursive Sorting
Mergesort with a Threshold
Java’s RecursiveAction Class
The Sorter’s Constructor
The Sorter’s compute Method
Using a ForkJoinPool to Get Concurrent Recursion Started
Beyond the Simple Sorter Class
Self-Test Exercises for Section 12.5
Chapter Summary
Solutions to Self-Test Exercises
Programming Projects
Chapter 13 Software Reuse with Extended Classes
Learning Objectives
Chapter Contents
13.1 Extended Classes
How to Declare an Extended Class
The Constructors of an Extended Class
Using an Extended Class
Descendants and Ancestors
Overriding Inherited Methods
Covariant Return Values
Widening Conversions for Extended Classes
Narrowing Conversions for Extended Classes
Self-Test Exercises for Section 13.1
13.2 Generic Type Parameters And Inheritance
Self-Test Exercise for Section 13.2
13.3 Simulation Of An Ecosystem
Implementing Part of the Organism Object Hierarchy
The Organism Class
The Animal Class: An Extended Class with New Private Instance Variables
How to Provide a New Constructor for an Extended Class
The Other Animal Methods
Self-Test Exercises for the Middle of Section 13.3
The Herbivore Class
The Pond Life Simulation Program
Pond Life—Implementation Details
Using the Pond Model
Self-Test Exercises for the End of Section 13.3
13.4 Abstract Classes And A Game Class
Introduction to the AbstractGame Class
Protected Methods
Final Methods
Abstract Methods
An Extended Class to Play Connect Four
The Private Member Variables of the Connect Four Class
Three Connect Four Methods That Deal with the Game’s Status
Three Connect Four Methods That Deal with Moves
The clone Method
Writing Your Own Derived Games from the AbstractGame Class
Self-Test Exercises for Section 13.4
Chapter Summary
Further Reading
Solutions to Self-Test Exercises
Programming Projects
Chapter 14 Generic
Learning Objectives
Chapter Contents
14.1 Graph Definitions
Undirected Graphs
Programming Example: Undirected State Graphs
Directed Graphs
More Graph Terminology
Airline Routes Example
Self-Test Exercises for Section 14.1
14.2 Graph Implementations
Representing Graphs with an Adjacency Matrix
Using a Two-Dimensional Array to Store an Adjacency Matrix
Representing Graphs with Edge Lists
Representing Graphs with Edge Sets
Which Representation Is Best?
Programming Example: Labeled Graph ADT
The Graph Constructor and size Method
Methods for Manipulating Edges
Methods for Manipulating Vertex Labels
Labeled Graph ADT—Implementation
Self-Test Exercises for Section 14.2
14.3 Graph Traversals
Depth-First Search
Breadth-First Search
Depth-First Search—Implementation
Breadth-First Search—Implementation
Self-Test Exercises for Section 14.3
14.4 Path Algorithms
Determining Whether a Path Exists
Graphs with Weighted Edges
Shortest-Distance Algorithm
Shortest-Path Algorithm
Self-Test Exercises for Section 14.4
Chapter Summary
Solutions to Self-Test Exercises
Programming Projects
Appendix A Java’s Primitive Types and Arithmetic Overflow
Special Properties of the char Type:
Appendix B Java Input and Output
The Scanner Class
Detecting and Reading Part of a Token with Patterns
The System.out.printf Method
Appendix C Throwing and Catching Java Exceptions
How to Throw an Exception
The RuntimeException and Error Classes
Catching an Exception
The throws Clause
Further Information
Appendix D ArrayList, Vector, Hashtable, and HashMap Classes
The java.util.Vector and java.util.ArrayList Classes
The Hashtable<K,V> and HashMap<K,V> Classes
Appendix E A Class for Nodes in a Linked List
Appendix F A Class for a Bag of Objects
Appendix G Further Big-O Notation
Formal Definition of Big-O
What Big-O Expressions Indicate
Appendix H Javadoc
How to Use Javadoc to Provide Your Work to Other Programmers
How to Write Javadoc Documentation Comments
Javadoc Documentation for a Description of the Whole Class
Javadoc Documentation for Individual Public Methods
Controlling html Links and Fonts
Running Javadoc
Appendix I Applets for Interactive Testing
Index
Symbols
Appendix I: Applets for Interactive Testing from Data Structures & Other Objects Using Java
Six Parts of a Simple Interactive Applet
How to Compile and Run an Applet
Beyond the init Method
What makes us different?
• Instant Download
• Always Competitive Pricing
• 100% Privacy
• FREE Sample Available
• 24-7 LIVE Customer Support