Data Abstraction and Problem Solving with Java: Walls and Mirrors

Janet Prichard / Carrano  
Total pages
February 2011
Related Titles

Product detail

Product Price CHF Available  
Data Abstraction and Problem Solving with Java: Walls and Mirrors
87.40 approx. 7-9 days


You'll find the eBook here.:

Free evaluation copy for lecturers


This edition of Data Abstraction and Problem Solving with Java: Walls and Mirrors employs the analogies of Walls (data abstraction) and Mirrors (recursion) to teach Java programming design solutions, in a way that beginning students find accessible. The book has a student-friendly pedagogical approach that carefully accounts for the strengths and weaknesses of the Java language. With this book, students will gain a solid foundation in data abstraction, object-oriented programming, and other problem-solving techniques.


  • The Classic Walls & Mirrors approach instills the use of both abstraction (the walls) and recursion (the mirrors) to design solutions to problems
  • Completely revised code to be compatible with the Java 6 platform
  • Early (chapter 1) and expanded review of the Java language
  • Concentrates on the core data abstraction and data structure topics
  • Contains examples that illustrate the role of classes and ADTs in the problem-solving process
  • Includes carefully designed, student-friendly pedagogy, including margin notes, key concept boxes, error and misconception warnings, and self-test exercises with answers

New to this Edition

  • Uses Java 6: This edition has been thoroughly revised to be compatible with the latest release of Java, known as Java 6. All code has been completely revised to be Java 6 compliant. Generics are also an important part of Java 6, and this material is discussed in depth in Chapter 9, and then used throughout the remainder of the collections in the text.
  • Enhanced Early Review of Java: We have increased the amount of coverage of the Java language in the first chapter of the book to help students make the transition from their introduction to Java course to this course. Chapter 1 provides a concise review of important Java material, including brief discussions on constructors, object equality, inheritance, and the Array class. A discussion of the Console class from Java 6 was also added to Chapter 1. Chapter 9 focuses on advanced Java techniques, and includes an enhanced discussion of how to create an iterator class.
  • Linked List: The node class for linked lists has been simplified. The implementation now assumes the node class is package access only, and the other classes in the same package have direct access to the data within a node. Students are asked to explore the implications of making the data private in a node as an exercise.
  • Updates the Use of the Java Collections Framework: The Java Collections Framework is discussed throughout the text, with a section added to show the JFC classes that parallel those presented in the text. The Deque class, added in Java 6, is presented in Chapter 8.
  • Other enhancements: Additional changes aimed at improving the overall usability of the text include new exercises and a new cleaner design that enhances the book’s readability.

Table of Contents

Preface xv
Chapter Dependency Chart xviii
PART ONE Problem-Solving Techniques 1
1 Review of Java Fundamentals 3
1.1 Language Basics 4
Comments 4
Identifiers and Keywords 4
Variables 4
Primitive Data Types 5
References 6
Literal Constants 6
Named Constants 7
Assignments and Expressions 8
Arrays 11
1.2 Selection Statements 14
The if Statement 15
The switch Statement 16
1.3 Iteration Statements 17
The while Statement 17
The for Statement 18
The do Statement 21
1.4 Program Structure 21
Packages 22
Classes 23
Data Fields 24
Methods 26
How to Access Members of an Object 30
Class Inheritance 30
1.5 Useful Java Classes 32
The Object Class 32
The Array Class 34
String Classes 35
1.6 Java Exceptions 40
Catching Exceptions 40
Throwing Exceptions 47
1.7 Text Input and Output 49
Input 49
Output 51
The Console Class 54
1.8 File Input and Output 56
Text Files 58
Object Serialization 66
Summary 69 Cautions 72 Self-Test Exercises 72
Exercises 73 Programming Problems 78

2 Principles of Programming and Software Engineering 81
2.1 Problem Solving and Software Engineering 82
What Is Problem Solving? 82
The Life Cycle of Software 83
What Is a Good Solution? 93
2.2 Achieving an Object-Oriented Design 95
Abstraction and Information Hiding 96
Object-Oriented Design 98
Functional Decomposition 100
General Design Guidelines 101
Modeling Object-Oriented Designs Using UML 102
Advantages of an Object-Oriented Approach 106
2.3 A Summary of Key Issues in Programming 107
Modularity 107
Modifiability 109
Ease of Use 111
Fail-Safe Programming 112
Style 118
Debugging 122
Summary 125 Cautions 126 Self-Test Exercises 126
Exercises 127 Programming Problems 132

3 Recursion: The Mirrors 137
3.1 Recursive Solutions 138
A Recursive Valued Method: The Factorial of n 141
A Recursive void Method: Writing a String Backward 148
3.2 Counting Things 159
Multiplying Rabbits (The Fibonacci Sequence) 159
Organizing a Parade 161
Mr. Spock’s Dilemma (Choosing k out of n Things) 164
3.3 Searching an Array 166
Finding the Largest Item in an Array 167
Binary Search 168
Finding the k th Smallest Item in an Array 172
3.4 Organizing Data 176
The Towers of Hanoi 176
3.5 Recursion and Efficiency 180
Summary 187 Cautions 187 Self-Test Exercises 188
Exercises 189 Programming Problems 195

4 Data Abstraction: The Walls 197
4.1 Abstract Data Types 198
4.2 Specifying ADTs 203
The ADT List 204
The ADT Sorted List 209
Designing an ADT 211
Axioms (Optional) 215
4.3 Implementing ADTs 218
Java Classes Revisited 219
Java Interfaces 221
Java Packages 224
An Array-Based Implementation of the ADT List 226
Summary 233 Cautions 233 Self-Test Exercises 234
Exercises 235 Programming Problems 238

5 Linked Lists 241
5.1 Preliminaries 242
Object References 242
Resizeable Arrays 248
Reference-Based Linked Lists 249
5.2 Programming with Linked Lists 253
Displaying the Contents of a Linked List 253
Deleting a Specified Node from a Linked List 255
Inserting a Node into a Specified Position of a Linked List 258
A Reference-Based Implementation of the ADT List 264
Comparing Array-Based and Reference-Based Implementations 268
Passing a Linked List to a Method 271
Processing Linked Lists Recursively 271
5.3 Variations of the Linked List 277
Tail References 277
Circular Linked Lists 278
Dummy Head Nodes 280
Doubly Linked Lists 280
5.4 Application: Maintaining an Inventory 284
5.5 The Java Collections Framework 290
Generics 291
Iterators 292
The Java Collection’s Framework List Interface 295
Summary 298 Cautions 300 Self-Test Exe

Instructor Resources