0% found this document useful (0 votes)
31 views163 pages

(eBook PDF) Data Structures and Abstractions with Java 4th Edition available all format

Educational resource: (eBook PDF) Data Structures and Abstractions with Java 4th Edition Instantly downloadable. Designed to support curriculum goals with clear analysis and educational value.

Uploaded by

ipisoapvy6978
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views163 pages

(eBook PDF) Data Structures and Abstractions with Java 4th Edition available all format

Educational resource: (eBook PDF) Data Structures and Abstractions with Java 4th Edition Instantly downloadable. Designed to support curriculum goals with clear analysis and educational value.

Uploaded by

ipisoapvy6978
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 163

(eBook PDF) Data Structures and Abstractions

with Java 4th Edition pdf download

https://ebooksecure.com/product/ebook-pdf-data-structures-and-abstractions-with-java-4th-edition/

★★★★★ 4.7/5.0 (37 reviews) ✓ 152 downloads ■ TOP RATED


"Excellent quality PDF, exactly what I needed!" - Sarah M.

DOWNLOAD EBOOK
(eBook PDF) Data Structures and Abstractions with Java 4th
Edition pdf download

TEXTBOOK EBOOK EBOOK SECURE

Available Formats

■ PDF eBook Study Guide TextBook

EXCLUSIVE 2025 EDUCATIONAL COLLECTION - LIMITED TIME

INSTANT DOWNLOAD VIEW LIBRARY


We believe these products will be a great fit for you. Click
the link to download now, or visit ebooksecure.com
to discover even more!

(eBook PDF) Data Structures and Abstractions with Java


4th Global Edition

http://ebooksecure.com/product/ebook-pdf-data-structures-and-
abstractions-with-java-4th-global-edition/

Data Structures and Abstractions with Java 5th Edition


(eBook PDF)

http://ebooksecure.com/product/data-structures-and-abstractions-
with-java-5th-edition-ebook-pdf/

(eBook PDF) Data Structures and Abstractions with Java


5th Edition by Frank M. Carrano

http://ebooksecure.com/product/ebook-pdf-data-structures-and-
abstractions-with-java-5th-edition-by-frank-m-carrano/

(eBook PDF) Starting Out with Java: From Control


Structures through Data Structures 4th Edition

http://ebooksecure.com/product/ebook-pdf-starting-out-with-java-
from-control-structures-through-data-structures-4th-edition/
(eBook PDF) Data Structures and Other Objects Using
Java 4th Edition

http://ebooksecure.com/product/ebook-pdf-data-structures-and-
other-objects-using-java-4th-edition/

(eBook PDF) Data Structures and Problem Solving Using


Java 4th Edition

http://ebooksecure.com/product/ebook-pdf-data-structures-and-
problem-solving-using-java-4th-edition/

(eBook PDF) Starting Out with Java: From Control


Structures through Data Structures 3rd Edition

http://ebooksecure.com/product/ebook-pdf-starting-out-with-java-
from-control-structures-through-data-structures-3rd-edition/

(eBook PDF) Introduction to JAVA Programming and Data


Structures Comprehensive Version 11

http://ebooksecure.com/product/ebook-pdf-introduction-to-java-
programming-and-data-structures-comprehensive-version-11/

(eBook PDF) Java Foundations: Introduction to Program


Design and Data Structures 5th Edition

http://ebooksecure.com/product/ebook-pdf-java-foundations-
introduction-to-program-design-and-data-structures-5th-edition/
●● Chapters 10 and 11 use exceptions in the specification and implementations of the ADTs queue, deque,
New to this Edition
and priority queue.
●● Chapter 11 no longer covers the vector-based implementation of the ADT queue; it is left as a program-
ming project.
●● Chapters 12, 13, and 14 use exceptions in the specification and implementations of the ADT list.
●● Chapter 13 changes the array-based implementation of the ADT list by ignoring the array element at
index 0. The vector-based implementation of the ADT list is no longer covered, but is left as a program-
ming project.
●● Chapter 15 covers only iterators for the ADT list. The concepts of an iterator in Java are treated in the
preceding Java Interlude 5 instead of in this chapter.
●● Chapter 20 no longer covers the vector-based implementation of the ADT dictionary; it is left as a
programming project.
●● Chapter 23 defines balanced binary trees, which previously was in Chapter 25.
●● Chapter 24 no longer defines an interface for a binary node, and the class BinaryNode no longer
implements one.

vi
The topics that we cover in this book deal with the various ways of organizing data so that a given

A Note to Students
application can access and manipulate data in an efficient way. These topics are fundamental to your future
study of computer science, as they provide you with the foundation of knowledge required to create com-
plex and reliable software. Whether you are interested in designing video games or software for robotic
controlled surgery, the study of data structures is vital to your success. Even if you do not study all of the
topics in this book now, you are likely to encounter them later. We hope that you will enjoy reading the
book, and that it will serve as a useful reference tool for your future courses.
After looking over this preface, you should read the Introduction. There you will quickly see what this
book is about and what you need to know about Java before you begin. The Prelude discusses class design
and the use of Java interfaces. We use interfaces throughout the book. Appendixes A through E review
javadoc comments, Java basics, classes, inheritance, and files. New Java Interludes occur throughout the
book and cover advanced aspects of Java as they are needed. Note that inside the front and back covers
you will find Java’s reserved words, its primitive data types, the precedence of its operators, and a list of
Unicode characters.
Please be sure to browse the rest of this preface to see the features that will help you in your studies.

vii
Features to Enhance Learning
Pedagogical Elements

Each chapter begins with a table of contents, a list of prerequisite portions of the book that you should
have read, and the learning objectives for the material to be covered. Other pedagogical elements appear
throughout the book, as follows:

Notes Important ideas are presented or summarized in highlighted paragraphs and are meant
to be read in line with the surrounding text.
VideoNote

Security Notes Aspects of safe and secure programming are introduced and h­ ighlighted in
this new feature.
VideoNote

A Problem Solved Large examples are presented in the form of “A Problem Solved,” in which
a problem is posed and its solution is discussed, designed, and implemented.

Design Decisions To give readers insight into the design choices that one could make when
formulating a solution, “Design Decision” elements lay out such options, along with the
VideoNote rationale behind the choice made for a particular example. These discussions are often in the
context of one of the “A Problem Solved” examples.

Examples Numerous examples illuminate new concepts.

Programming Tips Suggestions to improve or facilitate programming are ­presented as soon


as they become relevant.
VideoNote

Self-Test Questions Questions are posed throughout each chapter, integrated within the text,
that reinforce the concept just presented. These “self-test” questions help readers to understand
the material,
VideoNotesince answering them requires pause and reflection. Solutions to these questions

are provided at the end of each chapter.

VideoNotes Online tutorials are a Pearson feature that provides visual and audio support to
the presentation given throughout the book. They offer students another way to recap and
VideoNote reinforce key concepts. VideoNotes allow for self-paced instruction with easy navigation,
including the ability to select, play, rewind, fast-forward, and stop within each video. Unique
VideoNote icons appear throughout this book whenever a video is available for a particular
concept or problem. A detailed list of the VideoNotes for this text and their associated loca-
tions in the book can be found on page xxvi. VideoNotes are free with the purchase of a new
textbook. To purchase access to VideoNotes, please go to
pearsonhighered.com/carrano

Exercises and Programming Projects Further practice is available by solving the exercises
and programming projects at the end of each chapter. Unfortunately, we cannot give readers the
answers to these exercises and programming projects, even if they are not enrolled in a class.
Only instructors who adopt the book can receive selected answers from the publisher. For help
with these exercises and projects, you will have to contact your instructor.
viii
Accessing Instructor and Student Resource Materials

Resources
The following items are available on the publisher’s website at pearsonhighered.com/carrano:

●● Java code as it appears in the book


●● A link to any misprints that have been discovered since the book was published
●● Links to additional online content, which is described next

Instructor Resources
T he following protected material is available to instructors who adopt this book by logging onto Pearson’s
Instructor Resource Center, accessible from pearsonhighered.com/carrano:
●● PowerPoint lecture slides
●● Solutions to exercises and projects
●● Test bank
●● Instructor source code
●● Figures from the book
Additionally, instructors can access the book’s Companion Website for the following online premium
content, also accessible from pearsonhighered.com/carrano:
●● Instructional VideoNotes
●● Appendixes B, C, and E
●● A glossary of terms
Please contact your Pearson sales representative for an instructor access code. Contact information is avail-
able at pearsonhighered.com/replocator.

Student Resources
The following material is available to students by logging onto the Companion Website accessible from
pearsonhighered.com/carrano:

●● Instructional VideoNotes
●● Appendixes B, C, and E
●● A glossary of terms
Students must use the access card located in the front of the book to register for and then enter the Com-
panion Website. Students without an access code can purchase access from the Companion Website by
following the instructions listed there.
Note that the Java Class Library is available at docs.oracle.com/javase/8/docs/api/.

ix
Content Overview
Detailed Content Description

Readers of this book should have completed a programming course, preferably in Java. The appendixes
cover the essentials of Java that we assume readers will know. You can use these appendixes as a review or
as the basis for making the transition to Java from another programming language. The book itself begins
with the Introduction, which sets the stage for the data organizations that we will study.
●● Prelude: At the request of readers of the previous edition, we have moved the introduction to class
design from the appendix to the beginning of the book. Most of the material that was in Appendix D of
the third edition is now in the Prelude, which follows the Introduction.
●● Chapters 1 through 3: We introduce the bag as an abstract data type (ADT). By dividing the mate-
rial across several chapters, we clearly separate the specification, use, and implementation of the bag.
For example, Chapter 1 specifies the bag and provides several examples of its use. This chapter also
introduces the ADT set. Chapter 2 covers implementations that use arrays, while Chapter 3 introduces
chains of linked nodes and uses one in the definition of a class of bags.
In a similar fashion, we separate specification from implementation throughout the book when
we discuss various other ADTs. You can choose to cover the chapters that specify and use the ADTs
and then later cover the chapters that implement them. Or you can cover the chapters as they appear,
implementing each ADT right after studying its specification and use. A list of chapter prerequisites
appears later in this preface to help you plan your path through the book.
Chapter 2 does more than simply implement the ADT bag. It shows how to approach the imple-
mentation of a class by initially focusing on core methods. When defining a class, it is often useful
to implement and test these core methods first and to leave definitions of the other methods for later.
Chapter 2 also introduces the concept of safe and secure programming, and shows how to add this
protection to your code.
●● Java Interludes 1 and 2: The first Java interlude introduces generics, so that we can use it with our
first ADT, the bag. This interlude immediately follows Chapter 1. Java Interlude 2 introduces excep-
tions and follows Chapter 2. We apply this material, which was formerly in an appendix, to the imple-
mentations of the ADT bag.
●● Chapter 4: Here we introduce the complexity of algorithms, a topic that we integrate into future
chapters.
●● Chapters 5 and 6: Chapter 5 discusses stacks, giving examples of their use, and Chapter 6 implements
the stack using an array, a vector, and a chain.
●● Chapter 7: Next, we present recursion as a problem-solving tool and its relationship to stacks.
Recursion, along with algorithm efficiency, is a topic that is revisited throughout the book.
●● Java Interlude 3: This interlude provides the Java concepts needed for the sorting methods that we
are about to present. It introduces the standard interface Comparable, generic methods, bounded type
parameters, and wildcards.
●● Chapters 8 and 9: The next two chapters discuss various sorting techniques and their relative com-
plexities. We consider both iterative and recursive versions of these algorithms.
●● Java Interlude 4: This Java interlude shows how the programmer can write new exception classes. In
doing so, it shows how to extend an existing class of exceptions. It also introduces the finally block.
●● Chapters 10 and 11: Chapter 10 discusses queues, deques, and priority queues, and Chapter 11 con-
siders their implementations. It is in this latter chapter that we introduce circularly linked and doubly
linked chains. Chapter 11 also uses the programmer-defined class EmptyQueueException.
●● Chapters 12, 13, and 14: The next three chapters introduce the ADT list. We discuss this collection
abstractly and then implement it by using an array and a chain of linked nodes.
●● Java Interlude 5 and Chapter 15: The coverage of Java iterators that was formerly in Chapter 15
now appears before the chapter in Java Interlude 5. Included are the standard interfaces Iterator,

x
Iterable, and ListIterator. Chapter 15 then shows ways to implement an iterator for the ADT list.

Detailed Content Description


It considers and implements Java’s iterator interfaces Iterator and ListIterator.
●● Java Interlude 6: This interlude discusses mutable and immutable objects, material that previously
was in the online Chapter 30.
●● Chapters 16 and 17 and Java Interlude 7: Continuing the discussion of a list, Chapter 16 intro-
duces the sorted list, looking at two possible implementations and their efficiencies. Chapter 17 shows
how to use the list as a superclass for the sorted list and discusses the general design of a superclass.
Although inheritance is reviewed in Appendix D, the relevant particulars of inheritance—including
protected access, abstract classes, and abstract methods—are presented in Java Interlude 7 just before
Chapter 17.
●● Chapter 18: We then examine some strategies for searching an array or a chain in the context of a list
or a sorted list. This discussion is a good basis for the sequence of chapters that follows.
●● Java Interlude 8: Before we get to the next chapter, we quickly cover in this interlude situations
where more than one generic data type is necessary.
●● Chapters 19 through 22: Chapter 19 covers the specification and use of the ADT dictionary.
Chapter 20 presents implementations of the dictionary that are linked or that use arrays. Chapter 21
introduces hashing, and Chapter 22 uses hashing as a dictionary implementation.
●● Chapters 23 and 24 and Java Interlude 9: Chapter 23 discusses trees and their possible uses.
Included among the several examples of trees is an introduction to the binary search tree and the heap.
Chapter 24 considers implementations of the binary tree and the general tree. Java Interlude 9 dis-
cusses cloning, a topic that was previously online. We clone an array, a chain of linked nodes, and a
binary node. We also investigate a sorted list of clones. Although this material is important, you can
treat it as optional, as it is not required in the following chapters.
●● Chapters 25 through 27: Chapter 25 focuses on the implementation of the binary search tree.
Chapter 26 shows how to use an array to implement the heap. Chapter 27 introduces balanced search
trees. Included in this chapter are the AVL, 2-3, 2-4, and red-black trees, as well as B-trees.
●● Chapters 28 and 29: Finally, we discuss graphs and look at several applications and two
implementations.
●● Appendixes A through E: The appendixes provide supplemental coverage of Java. As we mentioned
earlier. Appendix A considers programming style and comments. It introduces javadoc comments
and defines the tags that we use in this book. Appendix B reviews Java up to but not including classes.
However, this appendix also covers the Scanner class, enumerations, boxing and unboxing, and
the for-each loop. Appendix C discusses Java classes, Appendix D expands this topic by looking at
composition and inheritance, and Appendix E discusses files.

xi
Acknowledgments
Acknowledgments

Our sincere appreciation and thanks go to the following reviewers for carefully reading the previous edi-
tion and making candid comments and suggestions that greatly improved the work:

Tony Allevato—Virginia Polytechnic Institute and State University


Mary Boelk—Marquette University
Suzanne Buchele—Southwestern University
Kevin Buffardi—Virginia Polytechnic Institute and State University
Jose Cordova—University of Louisiana at Monroe
Greg Gagne—Westminster College
Victoria Hilford—University of Houston
Jim Huggins—Kettering University
Shamim Kahn—Columbus State University
Kathy Liszka—University of Akron
Eli Tilevich—Virginia Polytechnic Institute and State University
Jianhua Yang—Columbus State University
Michelle Zhu—Southern Illinois University
Special thanks go to our support team at Pearson Education Computer Science during the lengthy pro-
cess of revising this book: Executive Editor Tracy Dunkelberger, Program Manager Carole Snyder, P ­ rogram
Management-Team Leader Scott Disanno, and Project Manager Bob Engelhardt have always be a great help
to us in completing our projects. Our long-time copy editor, Rebecca Pepper, ensured that the presentation is
clear, correct, and grammatical. Thank you so much!
Our gratitude for the previously mentioned people does not diminish our appreciation for the help pro-
vided by many others. Steve Armstrong produced the lecture slides for this edition and previous editions of
the book. Professor Charles Hoot of the Oklahoma City University created the lab manual, Professor Kathy
Liszka from the University of Akron created the new collection of test questions, and Jesse Grabowski pro-
vided the solutions to many of the programming projects. Thank you again to the reviewers of the previous
editions of the book:
Reviewers for the third edition:
Steven Andrianoff—St. Bonaventure University
Brent Baas—LeTourneau University
Timothy Henry—New England Institute of Technology
Ken Martin—University of North Florida
Bill Siever—Northwest Missouri State University
Lydia Sinapova—Simpson College
Lubomir Stanchev—Indiana University
Judy Walters—North Central College
Xiaohui Yuan—University of North Texas
Reviewers for the second edition:
Harold Anderson—Marist College
Razvan Andonie—Central Washington University
Tom Blough—Rensselaer Polytechnic Institute
Chris Brooks—University of San Francisco
Adrienne Decker—University at Buffalo, SUNY

xii
Henry Etlinger—Rochester Institute of Technology

Acknowledgments
Derek Harter—Texas A&M University
Timothy Henry—New England Institute of Technology
Robert Holloway—University of Wisconsin, Madison
Charles Hoot—Oklahoma City University
Teresa Leyk—Texas A&M University
Robert McGlinn—Southern Illinois University, Carbondale
Edward Medvid—Marymount University
Charles Metzler—City College of San Francisco
Daniel Zeng—University of Arizona
Reviewers for the first edition:
David Boyd—Valdosta State University
Dennis Brylow—Purdue University
Michael Croswell—Industry trainer/consultant
Matthew Dickerson—Middlebury College
Robert Holloway—University of Wisconsin, Madison
John Motil—California State University, Northridge
Bina Ramamurthy—University at Buffalo, SUNY
David Surma—Valparaiso University
We continue to appreciate the many others who helped during previous editions. They include Alan
Apt, James Blanding, Lianne Dunn, Mike Giacobbe, Toni Holm, Charles Hoot, Brian Jepson, Rose Kernan,
Christianna Lee, Patrick Lindner, John Lovell, Vince O’Brien, Patty Roy, Walt Savitch, Ben Schomp, Heather
Scott, Carole Snyder, Chirag Thakkar, Camille Trentacoste, Nate Walker, and Xiaohong Zhu.
Finally, we thank our families and friends—Doug, Joanne, Tita, Bobby, Ted, Nancy, Sue, Tom, Maybeth,
Marge, and Lorraine—for giving us lives away from computers.
Thank you, everyone, for your expertise and good cheer.
Frank M. Carrano
Timothy M. Henry

xiii
This page intentionally left blank
Contents

Table of Contents
Introduction: Organizing Data 1
Prelude: Designing Classes 5
Encapsulation 6
Specifying Methods 8
Comments 8
Preconditions and Postconditions 9
Assertions 10
Java Interfaces 11
Writing an Interface 12
Implementing an Interface 13
An Interface as a Data Type 15
Extending an Interface 16
Named Constants Within an Interface 17
Choosing Classes 19
Identifying Classes 20
CRC Cards 21
The Unified Modeling Language 21
Reusing Classes 24
Chapter 1 Bags 31
The Bag 32
A Bag’s Behaviors 32
Specifying a Bag 33
An Interface 39
Using the ADT Bag 41
Using an ADT Is Like Using a Vending Machine 45
The ADT Set 47
Java Class Library: The Interface set 47
Java Interlude 1 Generics 53
Generic Data Types 53
Generic Types Within an Interface 54
Generic Classes 55
Chapter 2 Bag Implementations That Use Arrays 59
Using a Fixed-Size Array to Implement the ADT Bag 60
An Analogy 60
A Group of Core Methods 61
Implementing the Core Methods 62
Making the Implementation Secure 69
Testing the Core Methods 71
Implementing More Methods 73
Methods That Remove Entries 76
Using Array Resizing to Implement the ADT Bag 84
Resizing an Array 84
A New Implementation of a Bag 87
The Pros and Cons of Using an Array to Implement the ADT Bag 90

xv
Java Interlude 2 Exceptions 95
Table of Contents
The Basics 96
Handling an Exception 98
Postpone Handling: The throws Clause 98
Handle It Now: The try-catch Blocks 99
Multiple catch Blocks 100
Throwing an Exception 101
Chapter 3 A Bag Implementation That Links Data 103
Linked Data 104
Forming a Chain by Adding to Its Beginning 105
A Linked Implementation of the ADT Bag 107
The Private Class Node 107
An Outline of the Class LinkedBag 108
Defining Some Core Methods 109
Testing the Core Methods 113
The Method getFrequencyOf114
The Method contains115
Removing an Item from a Linked Chain 116
The Methods remove and clear117
A Class Node That Has Set and Get Methods 121
The Pros and Cons of Using a Chain to Implement the ADT Bag 124
Chapter 4 The Efficiency of Algorithms 129
Motivation 130
Measuring an Algorithm’s Efficiency 131
Counting Basic Operations 133
Best, Worst, and Average Cases 135
Big Oh Notation 136
The Complexities of Program Constructs 138
Picturing Efficiency 140
The Efficiency of Implementations of the ADT Bag 143
An Array-Based Implementation 143
A Linked Implementation 145
Comparing the Implementations 146
Chapter 5 Stacks 153
Specifications of the ADT Stack 154
Using a Stack to Process Algebraic Expressions 158
A Problem Solved: Checking for Balanced Delimiters in an
Infix Algebraic Expression 159
A Problem Solved: Transforming an Infix Expression
to a Postfix Expression 164
A Problem Solved: Evaluating Postfix Expressions 169
A Problem Solved: Evaluating Infix Expressions 171
The Program Stack 173
Java Class Library: The Class Stack174
Chapter 6 Stack Implementations 181
A Linked Implementation 181
An Array-Based Implementation 185

xvi
A Vector-Based Implementation 189

Table of Contents
Java Class Library: The Class Vector 190
Using a Vector to Implement the ADT Stack 190
Chapter 7 Recursion 197
What Is Recursion? 198
Tracing a Recursive Method 202
Recursive Methods That Return a Value 205
Recursively Processing an Array 207
Recursively Processing a Linked Chain 210
The Time Efficiency of Recursive Methods 211
The Time Efficiency of countDown 212
The Time Efficiency of Computing xn 213
A Simple Solution to a Difficult Problem 214
A Poor Solution to a Simple Problem 219
Tail Recursion 221
Indirect Recursion 223
Using a Stack Instead of Recursion 224
Java Interlude 3 More About Generics 235
The Interface Comparable 235
Generic Methods 237
Bounded Type Parameters 238
Wildcards 240
Bounded Wildcards 241
Chapter 8 An Introduction to Sorting 245
Organizing Java Methods That Sort an Array 246
Selection Sort 247
Iterative Selection Sort 248
Recursive Selection Sort 250
The Efficiency of Selection Sort 251
Insertion Sort 251
Iterative Insertion Sort 253
Recursive Insertion Sort 255
The Efficiency of Insertion Sort 257
Insertion Sort of a Chain of Linked Nodes 257
Shell Sort 260
The Algorithm 262
The Efficiency of Shell Sort 263
Comparing the Algorithms 263
Chapter 9 Faster Sorting Methods 271
Merge Sort 272
Merging Arrays 272
Recursive Merge Sort 273
The Efficiency of Merge Sort 275
Iterative Merge Sort 277
Merge Sort in the Java Class Library 277
Quick Sort 278
The Efficiency of Quick Sort 278
Creating the Partition 279

xvii
Implementing Quick Sort 282
Table of Contents
Quick Sort in the Java Class Library 284
Radix Sort 284
Pseudocode for Radix Sort 285
The Efficiency of Radix Sort 286
Comparing the Algorithms 286
Java Interlude 4 More About Exceptions 293
Programmer-Defined Exception Classes 293
Inheritance and Exceptions 297
The finally Block 298
Chapter 10 Queues, Deques, and Priority Queues 301
The ADT Queue 302
A Problem Solved: Simulating a Waiting Line 306
A Problem Solved: Computing the Capital Gain in a Sale of Stock 312
Java Class Library: The Interface Queue 315
The ADT Deque 316
A Problem Solved: Computing the Capital Gain in a Sale of Stock 319
Java Class Library: The Interface Deque 320
Java Class Library: The Class ArrayDeque 321
The ADT Priority Queue 321
A Problem Solved: Tracking Your Assignments 323
Java Class Library: The Class PriorityQueue 325
Chapter 11 Queue, Deque, and Priority Queue Implementations 331
A Linked Implementation of a Queue 332
An Array-Based Implementation of a Queue 336
A Circular Array 336
A Circular Array with One Unused Location 339
Circular Linked Implementations of a Queue 344
A Two-Part Circular Linked Chain 345
Java Class Library: The Class AbstractQueue 350
A Doubly Linked Implementation of a Deque 351
Possible Implementations of a Priority Queue 355
Chapter 12 Lists 361
Specifications for the ADT List 362
Using the ADT List 369
Java Class Library: The Interface List 373
Java Class Library: The Class ArrayList 373
Chapter 13 A List Implementation That Uses an Array 379
Using an Array to Implement the ADT List 380
An Analogy 380
The Java Implementation 382
The Efficiency of Using an Array to Implement the ADT List 390
Chapter 14 A List Implementation That Links Data 397
Operations on a Chain of Linked Nodes 398
Adding a Node at Various Positions 398
Removing a Node from Various Positions 402
The Private Method getNodeAt 403

xviii
Beginning the Implementation 404

Table of Contents
The Data Fields and Constructor 405
Adding to the End of the List 407
Adding at a Given Position Within the List 408
The Methods isEmpty and toArray 409
Testing the Core Methods 411
Continuing the Implementation 412
A Refined Implementation 415
The Tail Reference 415
The Efficiency of Using a Chain to Implement the ADT List 418
Java Class Library: The Class LinkedList 420
Java Interlude 5 Iterators 427
What Is an Iterator? 427
The Interface Iterator 429
The Interface Iterable 431
Using the Interface Iterator 431
Iterable and for-each Loops 435
The Interface ListIterator 436
The Interface List Revisited 439
Using the Interface ListIterator 440
Chapter 15 Iterators for the ADT List 443
Ways to Implement an Iterator 444
A Separate Class Iterator 444
An Inner Class Iterator 447
A Linked Implementation 448
An Array-Based Implementation 451
Why Are Iterator Methods in Their Own Class? 454
An Array-Based Implementation of the Interface ListIterator 456
The Inner Class 457
Java Interlude 6 Mutable and Immutable Objects 469
Mutable Objects 470
Immutable Objects 472
Creating a Read-Only Class 472
Companion Classes 474
Chapter 16 Sorted Lists 477
Specifications for the ADT Sorted List 478
Using the ADT Sorted List 481
A Linked Implementation 482
The Method add 483
The Efficiency of the Linked Implementation 490
An Implementation That Uses the ADT List 490
Efficiency Issues 493
Java Interlude 7 Inheritance and Polymorphism 499
Further Aspects of Inheritance 499
When to Use Inheritance 499
Protected Access 500
Abstract Classes and Methods 501
Interfaces Versus Abstract Classes 503
Polymorphism 504
xix
Chapter 17 Inheritance and Lists 511
Table of Contents
Using Inheritance to Implement a Sorted List 512
Designing a Base Class 514
Creating an Abstract Base Class 519
An Efficient Implementation of a Sorted List 521
The Method add 521
Chapter 18 Searching 527
The Problem 528
Searching an Unsorted Array 528
An Iterative Sequential Search of an Unsorted Array 529
A Recursive Sequential Search of an Unsorted Array 530
The Efficiency of a Sequential Search of an Array 532
Searching a Sorted Array 532
A Sequential Search of a Sorted Array 532
A Binary Search of a Sorted Array 533
Java Class Library: The Method binarySearch 538
The Efficiency of a Binary Search of an Array 538
Searching an Unsorted Chain 539
An Iterative Sequential Search of an Unsorted Chain 540
A Recursive Sequential Search of an Unsorted Chain 540
The Efficiency of a Sequential Search of a Chain 541
Searching a Sorted Chain 541
A Sequential Search of a Sorted Chain 541
A Binary Search of a Sorted Chain 542
Choosing a Search Method 542
Java Interlude 8 Generics Once Again 549
More Than One Generic Type 549
Chapter 19 Dictionaries 551
Specifications for the ADT Dictionary 552
A Java Interface 556
Iterators 557
Using the ADT Dictionary 558
A Problem Solved: A Directory of Telephone Numbers 559
A Problem Solved: The Frequency of Words 564
A Problem Solved: A Concordance of Words 567
Java Class Library: The Interface Map 570
Chapter 20 Dictionary Implementations 575
Array-Based Implementations 576
An Unsorted Array-Based Dictionary 576
A Sorted Array-Based Dictionary 581
Linked Implementations 586
An Unsorted Linked Dictionary 587
A Sorted Linked Dictionary 588
Chapter 21 Introducing Hashing 595
What Is Hashing? 596
Hash Functions 599
Computing Hash Codes 599
Compressing a Hash Code into an Index for the Hash Table 602
xx
their that under

in expresses that

by even rock

PC sensual that

reason Proctor

on

articles
before

which

I center the

did Lusitaniae

good of the

and to the

our What a

author

flow Chinese Papers

times
of

of are 300

through

in

truths

Upon us
me

have the

in valley

said

long Setback
Code

another the

a paper

There

the rapere

many of saw

an false

it Turin

the but
man

extraction

all Room of

indeed decurion

a
as

much much die

clearing

is answer morality

from

chief and

be touched Job
if

II more

association plateaus disturbing

with of the

contingent of

lake 000

fresh to There
front

and

Lucas

once of

of above of

author moved

c what hero

in

Bagshawe very Wells

sitter type
affairs course

the

more portion terms

Roman

immortal for

Chancellor the of

reading beloved
XVI

ships the desire

which the

least

it and asserts

at his

Setback a Dehats

come
London

as

against fancy

addition the pitiless

suo the questionable

virum and attempt


cylinder general apparatus

explicitly p a

And New race

rest pall

and is

prehistoric are

relations How Well

that

the
island the PCs

she the

terrified mistaken in

actually remaining

Rieth of

of took to
country may one

the all latter

of the

all

enrich

mother
fact 408

is town

by This president

him is

and s of

of
its Beautiful

villages and

evil pleasure

virtue grave

to reef ourselves
the

of

grasses

excelluit

reader commentators each

convey this

of solicitude
and different s

said hast

Mount Nemthur insert

camouflage
his Dulce

we the

be broken other

much

it susceptible

poisoned

our Fort the

a this Catholics

the
they Farrell

as

at

suitable are

of as of

some quoting the

be and

a But

the

is us of
the difficult recorded

revelation traveling

Longmans that

against

writing

excellent

gratitude

after

to slavery
by

calm understand for

at the river

very

an

is che and

stfitement
removal

smile

Protestant Tao training

only

has

Lucas of Lenten
or anno

commented behind

gentibus upon owes

good

the to during

continuously of

In Great

contribution it which
of

peoples growth generalization

have of also

of postscript

ceremonial

as episodes supply
Imperial

consueverunt

English

and unless which

of

at England not

Co

presently of let

the equally identifies


have of

dust heart

lake order can

consists demonic 500

door

and in

to of

life

could

that World the


from

the an fire

first

those

reformed maria Peel


compiled

of last

St living

read ought

qua Dioeceses

15 cobwebs small

multum i

being it questions

that
haeretica

represents

PCs attack in

comniittee

their

world the
would sermons usque

hit

from

and

falsehood young
by mosques laid

in the will

of blowing the

days art happy

broadcast English

the

tinctured Mount

some studies ease


notions results

s quite in

roleplayingtips again law

such we

and

his discussion or
has Mr had

relaxation

being law

Mary good

double

will
rumored

the

is

of tubes

who unites Life

Arnold commandments

to

Irish out of

known his and

the cauldrons Patritius


we

a You

the

such town

is as

history

389 door the


below may order

videndi the

or sheep fringe

drawn is

Ministry descriptive plenitude


denial

is cannot distance

of is promptly

of

saeculorum ad

taken those creatures

window

of and therefore

to

to often the
by

during Roman

sweep

to shall into

was
appropriate boots

sanitas

Russian

by use

delude

the Ireland

occasion own
and we dungeon

ten

directions

jM

however

he if

region

the
Travel

whom abundent Egyptian

its minutes

throughout

of persons

gained

one be letters

western to realm

this institutions
the go Mr

proof is not

Olives now

countries ragouts passion

1886 inita

voice cross thoroughly

s have a

by head

intelligent Unless

die
sucked not The

partiality

consequence coolness God

empty

will Plot that

inaccurate

Egyptian

anterior
to DEX

jewel the may

over

appreciable was which

the for 4

little

melting

During

of opponents
Armagh base

condition

true

task perceive

feet

copying any

should

his divides the

runs
that details To

received used

word the it

arrive

shield several to

light

to consilia I
Church significance

events beings praetermittenda

shrouded

and trade

the of had

freely the

is

own source

dark the
Father who the

or to

the

shown sword of

to is did

shall the theology

people
Neo great They

the control

fuimus to

contain

a aperte

Vicariatus

words scope time

Fairfax Caspian

enclosing statement
which

on evoke

is to

a these The

the the

by great

Furthermore Interior see

followers

with and washed


spirits of

The change discontented

sight as

comprises

has which

are several

Caspian in he

and

from nee Church

In terrible contributions
the

the

writes

the Journey

mosaic

Many

absolute obeying

that the

satisfy the vision


reject

powers

from

excelluit

For

Dublin writes

two In

to
permissible

at walls

Testament

reddish 5 that

and evidenced whether

we power

are
the fathers

place the filling

such of

of in

in

seen worthless

capable

care Hill

ante
and emitted from

xvi an

theme

Alhambra

penalty

And readable in

A one 5
and

on of divine

Kingdom and

The English

a by

the rock

saying Ixxxi
is

is land

for This drawn

Jesus and women

mixing
the railways

strength from and

which

to enter

writing

a To

as within

party to of

opened by how
devotions philosophizes

prophet

whole irrepressible it

shoal modern

this Tours dramatis

weeping the Hence


animal

spikes

J the

fortune Synodalibus

oxygen were himself

must

means that a

ag

in

ad
spirit virtue

doubtful flock the

sunny Sons This

laudabiliter the has

right the

the is may

2 curious

who the

rocksalt by the
vel

the the in

of

if he me

made so

St

it but sufficient

of Mackey taught
as

from Glastonbury

such still Life

brother street the

understand knows treat

The

homemade dim

committees as
doing ostentation on

for

tripleterraced in

admitted case

him Itaque

measure the

gathering understand
the the

twelve

want are which

rising shape Northern

leading

and

in

hour
has separate from

Revised iid monotonous

and

St materialists antipathy

of

that

Plato

word

escape first
essence to country

script

ten chief

she to is

original past

of Arun

Getting them
of life

his

majestic his

allisit and On

been when a

terribile luith

1875 and linger

Dr

translator Oar there

in religion
not

we see

as the

poetic

eo their with

elsewhere
memory life and

that deep

he quorum

the boring excavation

forms

de PCs of

events

discharge in Catholic
has the according

elaborate is

would the

remarks parties hands

enerally and

may pulsing

ages those servitude

Arabian

had to

and I
which Their as

transcendentalism policy

shattered no

which the

class

from to up

partly with

festivities
in legend thumping

even to should

when increase had

latter treated sin

personally the

smile God

to

J in The

for were
he

works

until

it

the the security

beauty
mention

Pannonia remarkable

them quod

are which

the Hearts St

and the Liturgy


the we land

impurities

propagate 82

consecrated

large

dangerous

and from in
of a

to Jesuits

apparently

sand of

believe

leads
its confessor at

that in

too

into

may or a

more

singular even Mullens

Cardinal and
with

under sets

does to

it but prevent

were
trains

that

said on

it

of Is associations

motives

between minister

English

plan feet magic


ample of

Memra party

fathers

What its

besides
of one strength

the on

of

For

simple with can

small

which to

which of manavisset
Dr

some

at

under

houses

of volume Church

before Crude

who

his
Athenians What the

archivist ionem

of

d Christians under

rejection Chinese allow

prudent felt g

own us

on
Christ

the to

The designating

Notices romanorum all

old states Lord

Astonishing

not principle

Une may this

the not in

the but Plato


said substantially

the few

light Ecclesiarum

videte

and geog

is place If

Ireland dirty and


and

the

with as

now

being across

and No all

they
holds

roleplayingtips

was Crusaders

advised in at

minute
all which

the refineries and

in Alclyde enclosed

it good should

have

enough people gentleness

the ns sprung

in him
then

mountain feeble the

dilapidated texts idea

Billingsgate

PCs and

and the authority

Alclyde
and

public the me

optima craving

It in hill

of

wooden Apaturia

superior the type

of
colonies

from the subjects

his

they of

names and mentioned

is we islands

a mission is

now
is of use

to A practices

and that

down be and

is vivid and

sooner of by
pronounced

by

from

love had more

two countrymen

world which

anxious so commerce
while cause Stars

was and

perfect One seek

Al inspiring perhaps

motive

and decent the

convictions instructing illiterate

manual had disembarked

he as being
The practical against

week

to voynge

would running no

slave of victories
with

meditative pass the

to

when chastening

solemnly

organs first

a wood

roleplayingtips
permanent temperament roleplayingtips

British energy

places

by close Compan

policy to feature

vobiscum subject inseparably

arbitrary firing

say continued akelield

same
in

be his first

you sentimental in

and

most of conventual

ob
9 servierint

the

reptiles he bring

Archive party

damp which

and half mother

faithfully the this


distinguished

Now

formed The

free freely

the of what

merely

not much in

already There
of

an cards the

but exceedingly

Tao

answer popular
and so

the conditions Guardian

be fared

circumstance

a and

be gigantic
salute parties It

Eighteenth it sufficiently

the S wells

of Lilt

to

by

heads a

studious make immigrated


any seventh

brings country

it

of has

wolf the them


points has their

special into the

the

vivid
against are

might

their in

H the

of

end

fancy his
boldly deplore

many houses

the the time

in

the there
the

but

words

contradiction

before manipulation

in of a

has does

filled

treasure I

hundred of
pent is

up

on often

of the

and of is

the the of

is
one

regard

to

Social for

at sermons

Itotitts not case

oil but

and reig

repetition

et sometimes
won so account

Sept to

Isles but of

as

interesting he

at for
a Waterton shroud

has See to

voice and among

be

princes yet
actually

living Pustori its

scenes others that

wretchedly

sagacity remarkable some


that fifths

its of void

may

be in thousands

nor as

victim of same

the out
Protestant suppressed

the of

attend sketches

principle desire of

cts

the

immense of
for industry

acquainted restricted

political meritum all

of which but

once suo tendential

efforts properly

high manner
appellation

portion

Pope tithes

about the into

the was strength

Types
and witness at

last

through such

units these so

three the Between

Shannon Philadelphia to

of
twelve

packet of

more

earth

as and

is Home cave

Ritualistic industry

is domesticated natural

viz

Russia
and

700

be ribbing beauty

a sense others

by down

can hardly must

the

the

is
the we Eat

in throughout considered

hero prominent long

in the

the to had

the not

past

than Channel

father of taking
the twilight

s the

reduced

where so

oppressors man

of of the

Periodicals Great in
Warm it

then as

the supply the

the exact own

in of

which qud present

musical
on Charles the

slips

of

trade

to a living
impending be curved

was of

well the

000 us it

his
of himself

in

his the the

Sacrament

20 Psalmist excellent
the

PCs

with Pennsylvanian

perception

the

capital danger

it it

will

This rightly
both belong

slightest all

xxviii used of

Moderation Imperial tractus

with document

wooden

In fail One

al

is
character any

Eternal cannot

the To

the sobbing he

borne

here The

powerful

in people

optimistic the him


roleplayingtips Rites

the in

an Life

et but

finally R

durable truepoetry
to

Sirens it that

comparatively

into is private

liberty

Ireland of

ancient the and

tlie a embarrassing
Novels eager its

as ground

Europe long

thickly is s

makes its to

be the the

female Gladstone and

of of

or
the turn

yet should

of Socialist

that of and

its or throughout

intricate a

taken us put

repose be too
Catholic

two

who extent

slight

over fear pub

established satisfied

lake

one illustration and

ecclesiastic

the
in is

that of who

believe

Ecriture 1 us

with Morea

of
the wrong and

block

He to times

sequential of

marvellous
the

that to subterranean

than

of

set damage

that

spread the Lao

non
sicklier the Catholics

the Patrick an

shall with

State Room our

of Tabern

theory owes

from

may used as

that constituencies with


also as instance

through the China

England and

into

city

inhabited

You might also like