Skip to content

Data Structures and Abstractions with Java

Best in textbook rentals since 2012!

ISBN-10: 0136100910

ISBN-13: 9780136100911

Edition: 3rd 2012 (Revised)

Authors: Frank M. Carrano

List price: $157.60
Blue ribbon 30 day, 100% satisfaction guarantee!
what's this?
Rush Rewards U
Members Receive:
Carrot Coin icon
XP icon
You have reached 400 XP and carrot coins. That is the daily max!

Customers also bought

Book details

List price: $157.60
Edition: 3rd
Copyright year: 2012
Publisher: Prentice Hall PTR
Publication date: 9/13/2011
Binding: Hardcover
Pages: 1008
Size: 8.00" wide x 10.00" long x 1.25" tall
Weight: 3.850
Language: English

Introduction
Bags
The Bag
A Bag's Behaviors
Specifying a Bag
An Interface
Using the ADT Bag
Using an ADT Is Like Using a Vending Machine
Java Class Library: The Interface Set
Bag Implementations That Use Arrays
Using a Fixed-Size Array to Implement the ADT Bag
An Analogy
A Group of Core Methods
Implementing the Core Methods
Testing the Core Methods
Implementing More Methods
Methods That Remove Entries
Using Array Resizing to Implement the ADT Bag
Resizing an Array
A New Implementation of a Bag
The Pros and Cons of Using an Array to Implement the ADT Bag
A Bag Implementation That Links Data
Linked Data
Forming a Chain by Adding to Its Beginning
A Linked Implementation of the ADT Bag
The Private Class Node
An Outline of the Class Linked Bag
Defining Some Core Methods
Testing the Core Methods
The Method getFrequencyOf
The Method contains
Removing an Item from a Linked Chain
The Methods remove and clear
A Class Node That Has Set and Get Methods
The Pros and Cons of Using a Chain to Implement the ADT Bag
The Efficiency of Algorithms
Motivation
Measuring an Algorithm's Efficiency
Counting Basic Operations
Best, Worst, and Average Cases
Big Oh Notation
The Complexities of Program Constructs
Picturing Efficiency
The Efficiency of Implementations of the ADT Bag
An Array-Based Implementation
A Linked Implementation
Comparing the Implementations
Stacks
Specifications of the ADT Stack
Using a Stack to Process Algebraic Expressions
A Problem Solved: Checking for Balanced Delimiters in an Infix Algebraic Expression
A Problem Solved: Transforming an Infix Expression to a Postfix Expression
A Problem Solved: Evaluating Postfix Expressions
A Problem Solved: Evaluating Infix Expressions
The Program Stack
Java Class Library: The Class Stack
Stack Implementations
A Linked Implementation
An Array-Based Implementation
A Vector-Based Implementation
Java Class Library: The Class Vector
Using a Vector to Implement the ADT Stack
Recursion
What Is Recursion?
Tracing a Recursive Method
Recursive Methods That Return a Value
Recursively Processing an Array
Recursively Processing a Linked Chain
The Time Efficiency of Recursive Methods
The Time Efficiency of countDown
The Time Efficiency of Computing xn
A Simple Solution to a Difficult Problem
A Poor Solution to a Simple Problem
Tail Recursion
Indirect Recursion
Using a Stack Instead of Recursion
An Introduction to Sorting
Organizing Java Methods That Sort an Array
Selection Sort
Iterative Selection Sort
Recursive Selection Sort
The Efficiency of Selection Sort
Insertion Sort
Iterative Insertion Sort
Recursive Insertion Sort
The Efficiency of Insertion Sort
Insertion Sort of a Chain of Linked Nodes
Shell Sort
The Java Code
The Efficiency of Shell Sort
Comparing the Algorithms
Faster Sorting Methods
Merge Sort
Merging Arrays
Recursive Merge Sort
The Efficiency of Merge Sort
Iterative Merge Sort
Merge Sort in the Java Class Library
Quick Sort
The Efficiency of Quick Sort
Creating the Partition
Java Code for Quick Sort
Quick Sort in the Java Class Library
Radix Sort
Pseudocode for Radix Sort
The Efficiency of Radix Sort
Comparing the Algorithms
Queues, Deques, and Priority Queues
The ADT Queue
A Problem Solved: Simulating a Waiting Line
A Problem Solved: Computing the Capital Gain in a Sale of Stock
Java Class Library: The Interface Queue
The ADT Deque
A Problem Solved: Computing the Capital Gain in a Sale of Stock
Java Class Library: The Interface Deque
Java Class Library: The Class Array Deque
The ADT Priority Queue
A Problem Solved: Tracking Your Assignments
Java Class Library: The Class Priority Queue
Queue, Deque, and Priority Queue Implementations
A Linked Implementation of a Queue
An Array-Based Implementation of a Queue
A Circular Array
A Circular Array with One Unused Location
A Vector-Based Implementation of a Queue
Circular Linked Implementations of a Queue
A Two-Part Circular Linked Chain
Java Class Library: The Class Abstract Queue
A Doubly Linked Implementation of a Deque
Possible Implementations of a Priority Queue
Lists
Specifications for the ADT List
Using the ADT List
Java Class Library: The Interface List
Java Class Library: The Class Array List
List Implementations That Use Arrays
Using an Array to Implement the ADT List
An Analogy
The Java Implementation
The Efficiency of Using an Array to Implement the ADT List
Using a Vector to Implement the ADT List
A List Implementation That Links Data
Operations on a Chain of Linked Nodes
Adding a Node at Various Positions
Removing a Node from Various Positions
The Private Method get Node At
Beginning the Implementation
The Data Fields and Constructor
Adding to the End of the List
Adding at a Given Position Within the List
The Methods is Empty and to Array
Testing the Core Methods
Continuing the Implementation
A Refined Implementation
The Tail Reference
The Efficiency of Using a Chain to Implement the ADT List
Java Class Library: The Class Linked List
Iterators
What Is an Iterator?
The Interface Iterator
Using the Interface Iterator
A Separate Class Iterator
An Inner Class Iterator
A Linked Implementation
An Array-Based Implementation
Why Are Iterator Methods in Their Own Class?
The Interface List Iterator
Using the Interface List Iterator
An Array-Based Implementation of the Interface List Iterator
The Inner Class
Java Class Library: The Interface Iterable
Iterable and for-each loops
The Interface List Revisited
Sorted Lists
Specifications for the ADT Sorted List
Using the ADT Sorted List
A Linked Implementation
The Method add
The Efficiency of the Linked Implementation
An Implementation That Uses the ADT List
Efficiency Issues
Inheritance and Lists
Using Inheritance to Implement a Sorted List
Designing a Base Class
Creating an Abstract Base Class
An Efficient Implementation of a Sorted List
The Method add
Searching
The Problem
Searching an Unsorted Array
An Iterative Sequential Search of an Unsorted Array
A Recursive Sequential Search of an Unsorted Array
The Efficiency of a Sequential Search of an Array
Searching a Sorted Array
A Sequential Search of a Sorted Array
A Binary Search of a Sorted Array
Java Class Library: The Method binary Search
The Efficiency of a Binary Search of an Array
Searching an Unsorted Chain
An Iterative Sequential Search of an Unsorted Chain
A Recursive Sequential Search of an Unsorted Chain
The Efficiency of a Sequential Search of a Chain
Searching a Sorted Chain
A Sequential Search of a Sorted Chain
A Binary Search of a Sorted Chain
Choosing a Search Method
Dictionaries
Specifications for the ADT Dictionary
A Java Interface
Iterators
Using the ADT Dictionary
A Problem Solved: A Directory of Telephone Numbers
A Problem Solved: The Frequency of Words
A Problem Solved: A Concordance of Words
Java Class Library: The Interface Map
Dictionary Implementations
Array-Based Implementations
An Unsorted Array-Based Dictionary
A Sorted Array-Based Dictionary
Vector-Based Implementations
Linked Implementations
An Unsorted Linked Dictionary
A Sorted Linked Dictionary
Introducing Hashing
What Is Hashing?
Hash Functions
Computing Hash Codes
Compressing a Hash Code into an Index for the Hash Table
Resolving Collisions
Open Addressing with Linear Probing
Open Addressing with Quadratic Probing
Open Addressing with Double Hashing
A Potential Problem with Open Addressing
Separate Chaining
Hashing as a Dictionary Implementation
The Efficiency of Hashing
The Load Factor
The Cost of Open Addressing
The Cost of Separate Chaining
Rehashing
Comparing Schemes for Collision Resolution
A Dictionary Implementation That Uses Hashing
Entries in the Hash Table
Data Fields and Constructors
The Methods getValue, remove, and add
Iterators
Java Class Library: The Class Hash Map
Java Class Library: The Class Hash Set
Trees
Tree Concepts
Hierarchical Organizations
Tree Terminology
Traversals of a Tree
Traversals of a Binary Tree
Traversals of a General Tree
Java Interfaces for Trees
Interfaces for All Trees
An Interface for Binary Trees
Examples of Binary Trees
Expression Trees
Decision Trees
Binary Search Trees
Heaps
Examples of General Trees
Parse Trees
Game Trees
Tree Implementations
The Nodes in a Binary Tree
An Interface for a Node
An Implementation of BinaryNode
An Implementation of the ADT Binary Tree
Creating a Basic Binary Tree
The Method privateSetTree
Accessor and Mutator Methods
Computing the Height and Counting Nodes
Traversals
An Implementation of an Expression Tree
General Trees
A Node for a General Tree
Using a Binary Tree to Represent a General Tree
A Binary Search Tree Implementation
Getting Started
An Interface for the Binary Search Tree
Duplicate Entries
Beginning the Class Definition
Searching and Retrieving
Traversing
Adding an Entry
A Recursive Implementation
An Iterative Implementation
Removing an Entry
Removing an Entry Whose Node Is a Leaf
Removing an Entry Whose Node Has One Child
Removing an Entry Whose Node Has Two Children
Removing an Entry in the Root
A Recursive Implementation
An Iterative Implementation
The Efficiency of Operations
The Importance of Balance
The Order in Which Nodes Are Added
An Implementation of the ADT Dictionary
A Heap Implementation
Reprise: The ADT Heap
Using an Array to Represent a Heap
Adding an Entry
Removing the Root
Creating a Heap
Heap Sort
Balanced Search Trees
AVL Trees
Single Rotations
Double Rotations
Implementation Details
2-3 Trees
Searching a 2-3 Tree
Adding Entries to a 2-3 Tree
Splitting Nodes During Addition
2-4 Trees
Adding Entries to a 2-4 Tree
Comparing AVL, 2-3, and 2-4 Trees
Red-Black Trees
Properties of a Red-Black Tree
Adding Entries to a Red-Black Tree
Java Class Library: The Class Tree Map
B-Trees
Graphs
Some Examples and Terminology
Road Maps
Airline Routes
Mazes
Course Prerequisites
Trees
Traversals
Breadth-First Traversal
Depth-First Traversal
Topological Order
Paths
Finding a Path
The Shortest Path in an Unweighted Graph
The Shortest Path in a Weighted Graph
Java Interfaces for the ADT Graph
Graph Implementations
An Overview of Two Implementations
The Adjacency Matrix
The Adjacency List
Vertices and Edges
Specifying the Class Vertex
The Inner Class Edge
Implementing the Class Vertex
An Implementation of the ADT Graph
Basic Operations
Graph Algorithms
Mutable, Immutable, and Cloneable Objects Online
Mutable and Immutable Objects 30-2
Creating a Read-Only Class 30-4
Companion Classes 30-6
Cloneable Objects 30-8
Cloning an Array 30-14
Cloning a Chain 30-16
A Sorted List of Clones 30-19
Appendices
Java Essentials A-1
Introduction A-2
Applications and Applets A-2
Objects and Classes A-3
A First Java Application Program A-3
Java Basics A-5
Identifiers A-5
Reserved Words A-6
Variables A-6
Primitive Types A-7
Constants A-7
Assignment Statements A-8
Assignment Compatibilities A-9
Type Casting A-9
Arithmetic Operators and Expressions A-10
Parentheses and Precedence Rules A-11
Increment and Decrement Operators A-12
Special Assignment Operators A-13
Named Constants A-14
The Class Math A-15
Simple Input and Output Using the Keyboard and Screen A-15
Screen Output A-15
Keyboard Input Using the Class Scanner A-17
The if-else Statement A-19
Boolean Expressions A-20
Nested Statements A-23
Multiway if-else Statements A-24
The Conditional Operator (Optional) A-25
The switch Statement A-26
Enumerations A-28
Scope A-30
Loops A-30
The while Statement A-31
The for Statement A-32
The do-while Statement A-34
Additional Loop Information A-35
The Class String A-36
Characters Within Strings A-36
Concatenation of Strings A-37
String Methods A-38
The Class StringBuilder A-40
Using Scanner to Extract Pieces of a String A-42
Arrays A-44
Array Parameters and Returned Values A-46
Initializing Arrays A-47
Array Index Out of Bounds A-47
Use of = and == with Arrays A-47
Arrays and the For-Each Loop A-48
Multidimensional Arrays A-49
Wrapper Classes A-51
Java Classes B-1
Objects and Classes B-1
Using the Methods in a Java Class B-3
References and Aliases B-4
Defining a Java Class B-5
Method Definitions B-7
Arguments and Parameters B-9
Passing Arguments B-9
A Definition of the Class Name B-13
Constructors B-15
The Method toString B-17
Methods That Call Other Methods B-17
Methods That Return an Instance of Their Class B-19
Static Fields and Methods B-19
Overloading Methods B-21
Enumeration as a Class B-22
Packages B-25
The Java Class Library B-25
Generic Data Types B-26
Creating Classes from Other Classes C-1
Composition C-2
Adapters C-4
Inheritance C-5
Invoking Constructors from Within Constructors C-9
Private Fields and Methods of the Superclass C-10
Protected Access C-11
Overriding and Overloading Methods C-11
Multiple Inheritance C-16
Type Compatibility and Superclasses C-16
The Class Object C-18
Abstract Classes and Methods C-19
Polymorphism C-21
Designing Classes D-1
Encapsulation D-2
Specifying Methods D-4
Comments D-4
Preconditions and Postconditions D-5
Assertions D-6
Java Interfaces D-7
Writing an Interface D-8
Implementing an Interface D-10
An Interface as a Data Type D-11
Generic Types Within an Interface D-12
Extending an Interface D-14
Interfaces Versus Abstract Classes D-15
Named Constants Within an Interface D-17
Choosing Classes D-18
Identifying Classes D-20
CRC Cards D-20
The Unified Modeling Language D-21
Reusing Classes D-23
Handling Exceptions E-1
The Basics E-2
Handling an Exception E-4
Postpone Handling: The throws Clause E-4
Handle It Now: The try-catch Blocks E-5
Multiple catch Blocks E-6
Throwing an Exception E-8
Programmer-Defined Exception Classes E-9
Inheritance and Exceptions E-14
The finally Block E-15
File Input and Output F-1
Preliminaries F-2
Why Files? F-2
Streams F-2
The Kinds of Files F-3
File Names F-3
Text Files F-3
Creating a Text File F-3
Reading a Text File F-8
Changing Existing Data in a Text File F-12
Defining a Method to Open a Stream F-13
Binary Files F-13
Creating a Binary File of Primitive Data F-14
Reading a Binary File of Primitive Data F-18
Strings in a Binary File F-20
Object Serialization F-23
Documentation and Programming Style G-1
Naming Variables and Classes G-1
Indenting G-2
Comments G-2
Single-Line Comments G-3
Comment Blocks G-3
When to Write Comments G-3
Java Documentation Comments G-3
Running javadoc G-5
Glossary Online
Index I-1