Java: Data Structures and Programming Springer Berlin Heidelberg New York Barcelona Budapest Hong Kong London Milan Paris Singapore Tokyo Liwu Li Java: Data Structures and Programming With 44 Figures Including CD-ROM " Springer Professor Liwu Li University of Windsor, School of Computer Science 401 Sunset, Windsor, Ontario N9B 3P4 Canada E-mail: liwu@cs.uwindsor.ca Library of Congress Cataloging-in-Publication Data Li, Liwu Java: data structures and programming/Liwu Li p cm Includes bibliographical references and index Java (Computer program language) (Computer science) I Title QA76.73.J38L5 1998 005.7'3 dc21 Data structures 98-25666 CIP Springer-Verlag Berlin Heidelberg NewYork This work is subject to copyright All rights are reserved, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on micro-film or in any other way, and storage in data banks Duplication of this publication or parts thereof is permitted only under the provisions of the German Copyright Law of September 9,1965, in its current version, and permission for use must always be obtained from Springer-Verlag Violations are liable for prosecution under the German Copyright Law © Springer-Verlag Berlin Heidelberg 1998 Softcover reprint of the hardcover 1st edition 1998 ISBN- 13: 978-3-642-95853-3 e-ISBN- 13: 978-3-642-95851-9 DOl: 10.1 007/978-3-642-95851-9 Preface This book is written for practitioners of software development and for students of computer science who are interested in using the Java language to construct data structures The book assumes general knowledge of computer programming but no experience of Java programming or object modeling for the readers It introduces the Java language and object model by going through examples of data modeling The book emphasizes programming skills for developing various types of data structure and fundamental techniques for complexity analysis The programming skills are necessary for software development The analysis techniques are needed to ensure performance of programs The author has been responsible for teaching a data structure course for years The book carries out his expectations for proficiency in both programming and complexity analysis from students Several features of the book distinguish it from other books on data structures A challenge for the book is relating the complexity analysis to the Java Virtual Machine, which isolates Java programmers from platform issues The book devotes a chapter to discuss the structure of Java class files and the Java Virtual Machine The book presents the problem of maximum flow and implements algorithms in Java to evaluate maximum flow for networks It introduces persistent data structures, which may be included by some practitioners in their projects As a faculty member of School of Computer Science at University of Windsor, the author acknowledges the opportunity of teaching and research provided by the university The author is grateful for encourages the author received from his colleagues and students while the,book was prepared The whole process of the book preparation was consistently supported by Dr Hans Wossner, Executive Editor, Computer Science Editorial I at SpringerVerlag The author is particularly grateful for the careful reviewing arranged by Springer-Verlag, which helped removing some weaknesses from the manuscript of the book J Andrew Ross, English Copy Editor, and Peter Strasser, Production Editor at Springer-Verlag, gave valuable suggestions and comments on the manuscript The author is solely responsible for any errors in the book Comments on the book are welcome The author can be reached at liwu@cs.uwindsor.ca VI Preface Overview The Java language is widely accepted for software development due to its portability, type safety, security, and other interesting features It is attractive for Web applications For quality software, we often need to design customized data structures for different applications Data structures are indispensable components of software systems to support functionality of the systems and for efficient storage, retrieval, and manipulation of information The book is an introduction to programming object-oriented data structures in Java Object-oriented programming languages are founded on an object model The skill of object-oriented analysis and the knowledge of the Java language are necessities for Java data structure programmers The book presents the Java object model for application analysis and the Java language for data structure programming The success of Java is attributable to the Java Virtual Machine (JVM) Here we present the JVM as an abstract machine like a traditional Turing or random access machine To take the full advantage of the Java language, the book relates the analysis of programs and data structures with the JVM The book presents common data structure classes in Java The data structures include linear linked lists, trees, graphs, and networks Most non-trivial applications need data persistence and/or data transportation Java provides a mechanism for object serialization and deserialization The book presents the Java serialization mechanism and introduces an approach to serializing data structures for efficient storage and transportation Contents The book is divided into four parts: • • • • Part I introduces Java programming It shows how Java supports the object concepts and how to apply the Java constructs for data modeling It presents the Java language and the Java standard data structure classes The fIrst part of the book consists of Chapters 1,2,3, and Part II presents the JVM as an abstract machine It relates the analysis of data structures with the JVM It introduces basic notions for algorithm analysis and applies the notions for Java programs The second part consists of Chapters and Part m presents classes for linear linked lists, trees, graphs, and networks This part dedicates one chapter for each of the data structures It consists of Chapters 7, 8,9, and 10 Part IV presents the classes and interfaces of the Java serialization mechanism It shows how to apply the mechanism to generate efficient serial representations of data structures The part consists of Chapters 11 and 12 Preface VII The book leaves some exercises in the running text The exercises are relevant to the discussed topics Some of the exercises are programming exercises The book presents assignments at the end of some chapters The assignments can be used to practice the topics or notions presented in the chapters Roadmaps We present a roadmap for each part of the book in the following The roadmaps guide reading by interests Part I of the book looks at how to apply object-oriented concepts in application analysis and how to construct Java programs It presents the Java object model by studying a simplified supermarket It introduces the Java language and the standard Java data structures Graphics user interfaces (GUIs) should be used for users to enter data into data structures and retrieve data from a system Part I shows how to construct GUIs As shown in Fig 1, Chapters and are relatively independent from each other Chapter introduces Java constructs with examples Chapter presents the Java language A reader may start Java programming by reading Chapter and then going to Chapter without reading Chapter Chapter presents the Java data structure classes It extends the functionality of the Java language Part I is for self-containment of the book A reader who is familiar with the Java language and has sufficient Java programming experience can skip the part The part assumes some computer programming experience for readers A reader with no experience of object-oriented programming or knowledge of objectoriented languages may fmd the part helpful yes yes Chapter Data Modeling in Java Chapter The Java Language Chapter Programming in Java Chapter Java Data Structures Fig Roadmap for Part I VlII Preface As shown in Fig 2, Chapter is based on Chapter 5, which presents the NM as an abstract computational model Chapter discusses the various types of NM instructions with respect to time and space requirement Chapter introduces the noyes tion of analysis for algorithms and data structures that are implemented in Java It lays the foundation for designing efficient data structures and algorithms ChapterS in Java Java Virtual Machine Chapters 7,8,9, and 10 in Part III are independent from each other They present different types of data structure A reader may read the chapters in any order However, the inherent complexity of the data structures increases from Chapters to 10 For example, a student may find reading Chapter is easier than fIrst reading other chapters Reading Chapter helps understand other chapters Chapter 10 presents advanced algorithms for maximizing network flows An instructor may skip the chapter in a junior undergraduate course Part III analyzes some algorithms implemented in Java as well as presenting data structure classes It Chapter discusses the correctness and efficiency of the Java Complexity Analysis programs This part is the core of the book Readers can apply and adapt the classes in their programs In Part IV, Chapter 11 introduces the Java seFig Roadmap for Part II rialization mechanism Chapter 12 depends on Chapter 11 It discusses how to serialize data structures Font Use The book uses only two fonts - courier and times - for text The fonts are used as follows: • The fIxed width courier font is used for Java source code SpecifIcally, Java classes and methods are displayed in the font For example, the Java source code for class Person is shown in courier as Class Person { String name, address, telephonei • Running text is displayed in times font Emphasized words and Java expressions in running text are italicized For example, the identifIer for instance variable name defmed in the above Person class is displayed as name in the running text Preface yes IX yes Chapter Linear Data Structures Chapter Trees yes Chapter Graphs yes Chapter 10 Network Flows Fig Roadmap for Part III Programs All the Java source code listed inside the book is included in the CD of the book The Java classes can be copied to a hard-drive disk and compiled with the Java compiler For example, the Java file Customer java for Example 1.1 can be compiled by issuing command javac Customer java in the directory the contains the file After compilation, the main method in the class can be executed with command java Customer Compiled bytecode for the example classes is also included in the CD A reader can run a compiled main method before compiling the source code The Java source code was prepared with Sun's JDK 1.1, which includes a Java compiler and a runtime system Visit Sun's Web site at http://java.sun.com for information on the latest release of Sun's JDK for a platform Because of backward compatibility, the source code provided in the CD of the book can be compiled and run with later releases of Sun's JDK The yes Chapter 11 Object Serialization yes Chapter 12 Data Structure Serialization Fig Roadmap for Part IV X Preface author of the book will make efforts in updating the book to keep pace with the rapid development of Java 12.4 Summary } } 467 System.out.print( customersGraph1.isAdjacent(O, 1)); } catch(Exception eel { ee.printStackTrace(); } o Exercise 12.4 Extend class Graph that uses a matrix to represent adjacencies for undirected, unweighted graphs with a subclass, which implements interface Externalizable The subclass defmes the writeExternal and readExternal methods to serialize and deserialize the vertices array and adjacency matrix 12.4 Summary A data structure can be serialized if the class of the data structure implements interface Serializable or Externalizable When the class implements interface Serializable, it may defme a writeObject method, which can be used to serialize nonserializable fields In this chapter, we show how to implement interface Externalizable for common data structures - linked lists, trees, and graphs The externalizable data structures have a writeExternal method, which generates a more compact serial representation of a data structure than the default Java serialization The space efficiency is implied by eliminating the storage of auxiliary data structures such as nodes and vectors The readExternal method of the externalizable data structures deserializes the serial representation of a data structure and uses the persistent data to build a new data structure Assignment A B-tree is a balanced tree data structure for keeping keys Extend class B_Tree defmed in Chapter with an externalizable subclass The writeExternal and readExternal methods of the subclass are responsible for serializing a B-tree and de serializing a serialized B-tree, respectively Compare the compactness of the external representation of a B-tree with the serial representation of the B-tree generated with the default serialization mechanism of Java Appendix A Binary File Dumping A Hexadecimal Convertion of Binary Files A Java class file is a binary file with information represented in bits The main method of the following utility class, class dumpfile, can be used to convert a binary class file into a hexadecimal representation It creates a data input stream, called dataln, that encapsulates the class file The method uses a byte array named line of 16 bytes long to hold bytes read from the input stream The read operation is performed with statement bytes = dataln.read(line)i where bytes is an integer variable for holding the number of bytes read from the dataln stream Each line in the hexadecimal representation is prefixed with an offset from the beginning of the representation The offset is a four-digit hexadecimal number The main method converts a byte denoted with line[i] to two hexadecimal digits with the expressions Character.toUpperCase(Character forDigit«line[i] & OxFO) »4, 16» Character.toUpperCase(Character forDigit«line[i] & OxF) , 16» The first expression retrieves the first four bits of the byte and converts the binary integer to an upper case hexadecimal digit; the second converts the last four bits of the byte Class dumpfile can be compiled by a Java compiler To use the main method of the class to convert a class file, say Customer class, to its hexadecimal representation, issue command java dumpfile Customer class The main method of the dumpfile class invokes println method to print the hexadecimal conversion of class file Customer class on the standard output device /** * * * */ Dump a binary representation of a class file to hexadecimal representation by converting each byte to two digits Usage: java dumpfile import java.io.*i class dumpfile { public static void main(String[] args) { 470 Appendix A Binary File Dumping byte[] line = new byte [16] ; DataInputStream dataIn; try { FileInputStream fin = new FileInputStream(args[O]); data In = new DataInputStream(fin) ; int bytes = 1, lineNo = OxO; while (bytes > 0) { bytes = dataIn.read(line); i f (bytes > 0) { String liNo = Integer toHexString (lineNo) ; while (liNo.length() < 4) liNo = "0" + liNo; System.out.print(IOxl+liNo+" I II); lineNo += 16; } for (int i = 0; i < bytes; i++) { System.out.print("" + Character.toUpperCase( Character.forDigit((line[i]& OxFO) »4, 16)) + Character.toUpperCase( Character.forDigit((line[i]& OxF), 16)) + i ' ) ; System.out.println("") ; catch(FileNotFoundException e) { System.out.println("No such file ll ) ; catch(IOException e) { } } A2 Reading Utf8 Strings A class file may encode Utf8 strings To read a Utf8 string, invoke the readUTF method for a data input stream that represents the class file Before the method is executed, skip the bytes that are preceded the Utf8 string in the class file The following main method shows an example of reading a Utf8 string In the main method, expression dataIn.skipBytes(Ox2A) ; is used to skip Ox2A = 42 bytes in class file Merchandise.class Statement A2 Reading UtfB Strings 471 System.out.print(DatalnputStream.readUTF(dataln»; reads the UtfS string at position Ox002a in the class file and prints the string on the standard output import java.io.*; class dumpfile { public static void main(String[] args) { byte[] line = new byte [16] ; DatalnputStream dataln; try { FilelnputStream fin = new FilelnputStream("Merchandise.class"); dataln = new DatalnputStream(fin) ; dataln.skipBytes(Ox2A) ; System.out.print( DatalnputStream.readUTF(dataln»; } } } catch(FileNotFoundException e) { System.out.println("No such file ll ) ; catch(IOException e) { } } Appendix B References Chapter Object-oriented programming in Java is discussed in [1] [1] K Arnold and J Gosling The Java Programming Language AddisonWesley, Reading, Mass., 1996 Chapter The Java programming language is specified in [1] and [2] [2] J Gosling, B Joy and G Steele The Java Language Specification AddisonWesley, Reading, Mass., 1996 Chapter The Java Virtual Machine description is based on [3] [3] T Lindholm and F Yellin The Java Virtual Machine Specification AddisonWesley, Reading, Mass., 1997 Chapter For the analysis of the interpolation search algorithms, see [4], [5], and [6] The sorting methods, binary search, interpolation search and Fibonaccian search are discussed in [7] [4] A C Yao and F F Yao The Complexity of Searching an Ordered Random Table Proceedings of the 17th Annual IEEE Symposium on Foundations of Computer Science, 1976, pp 173-176 [5] Y Perl, A ltai, and H Avni Interpolation Search - A Log Log N Search CACM 21 (1978) pp 550-553 [6] G H Gonnet, L D Rogers, and J A George An Algorithmic and Complexity Analysis of Interpolation Search Acta Informatica 13 (1980) pp 3952 474 Appendix B References [7] D E Knuth The Art of Computer Programming, Volume 3, Sorting and Searching Addison-Wesley, Reading, Mass., 1973 Chapter Trees have been extensively discussed as a fundamental data structure in the literature Presentations on trees can be found in [8], [9], and [10] [8] A V Aho, J E Hopcroft, and J D Ullman The Design and Analysis of Computer Algorithms Addison-Wesley, Reading, Mass.,1974 [9] D E Knuth The Art of Computer Programming, Volume 1, Funadamental Algorithms Addison-Wesley, Reading, Mass., 1968, 1973 [10] R E Tarjan Data Structures and Network Algorithms, Regional Conference Series in Applied Mathematics, Volume 44 SIAM, 1983 [11] R Bayer Binary b-trees for virtual memory Proceedings of ACM SIGFIDET Workshop, ACM, 1971, pp 219-235 [12] R Bayer Symmetric binary b-trees: Data structure and maintenance algorithms Acta Informatica 1(1972) pp 290-306 Chapter The distances method follows an algorithm described in [13] The algorithm for method allDistances is due to [14] Both algorithms can be found in [8] [13] E W Dijkstra A note on two problems in connexion with graphs Numerische Mathematik (1959) pp 269-271 [14] S C Kleene Representation of events in nerve nets and fmite automata Automata Studies (1956), Shannon and McCarthy, eds., Princeton University Press, pp 3-40 Chapter 10 The pathSaturate method in class LeveledNetwork follows an algorithm by Dinic [15] The original algorithm for method vertexSaturate is due to [16] The method is based on a simplified version of the algorithm described in [10] The simplified Karzanov's algorithm is called wave method The Dinie's algorithm and wave method can be found in [10] [15] E A Dinic Algorithm for solution ofa problem of maximum flow in a network with power estimation Soviet Math Dokl 11 (1970) pp 1277-1280 Appendix B References 475 [16] A V Karzanov Determining the maximum flow in a network by the method of preflows Soviet Math Dokl 15 (1974) pp 434-437 Chapter 11 The Java serialization mechanism is defmed in Java Object Serialization Specification [17], which can be downloaded from http://java.sun.com The serialization specification describes interfaces Seriplizable and Externalizable, classes ObjectOutputStream and ObjectlnputStream Object stream format and constants for serializations of objects are also defmed in the specification [17] Java Object Serialization Specification Sun Microsystems, Mountain View, Ca., 1997 Index A abstract· 39 Abstract Windowing Toolkit· See AWT access mode package' 39 private' 39 protected' 39 public' 36 access modifier' 36,38 access, array element· 209 access, object field· 208 accesser' 10 See also method action listener' 133 ActionEvent 130 ActionListener' 115, 130, 132 adapter' 140 adapter class' 100, 102 addition + 81 See also concatenation adjacency matrix' 348 adjacency set· 346 adjacency vector' 348, 356, 383 Adjustable' 130 AdjustmentEvent· 130 all distances problem· 380 ancestor-descendant relation' 223 anonymous class' 97 See also inner class anonymous variable' 146 applet· 57,103,104-9,114 Applet· 103, 105, 109, 114, 140 appletviewer' 105 application' 103, 104, 109-11, 140 argument value passing' 23 arithmetic operation' 184, 207 array' 5,6,7,10,13,141,142-46,161, 229 creation' 25, 142 index' 144 length· 144 multi-dimensional' 145, 146 object· 143 type' 142, 145 variable' 143, 144, 145 Array' 93 array creation' 205 array serialization' 426 ArraylndexOutOjBoundsException· 142 ASCII character' 171 assignment· See also statement asymptotic analysis· 202, 218, 226 AVL_Tree' 313, 323 AVL-tree 272, 306, 307, 323, 325, 342 AWT·I03 A WTEvent 128 B B_Tree' 329 back reference' 419,422 balance' 306 behavior' See method benchmark' 201 best-case analysis· 212 big-a· 218 big-Oh· 216 binary representation of tree' 289 binary search· 221 binary search tree' 271, 303, 342 binary tree' 271,283,342 BinarySearchTree' 304 BinaryTree 285 BitSet· 142, 160-61 block' 61 initialization' 28 static 28, 29 boolean' 19,92 Boolean' 92 boolean literal' 59 BorderLayout· 122 breadth-first traversal, 293, 294, 344, 365,368,373,383 break· 61,65,66,67 browser' 104 B-tree'272,327,340,342 bubble sort· 212 BufJeredlnputStream 85 BufJeredOutputStream 85 business logic' 111 478 Index button' 110, 133 Button' 121 byte' 93 Byte' 93 byte array' 87 ByteArraylnputStream 87 ByteArrayOutputStream 87 bytecode·3 bytecode instruction 177 c Canvas' 121 capacity· 159,385,386 capacity restraint· 387 CardLayout 122 catch' 72 catch clause' 69, 71 char' 59,92 Character' 92 Checkbox' 121 child· 273 Choice' 121 class' 26-47, 101 abstract· 39 final class' 39 Class' 93, 94 class description' 422 class file 93, 165, 166, 199 class name classpath 36 clipping region' 112 comment C++-style· 58 C-style' 58 documentation· 16,58 compilation unit· 12,36 compiled method· 174 complex instruction' 211 complexity· 203 complexity category' 219 component· 117 Component· 119,120 ComponentEvent 129 computation model 201, 202, 226 concatenation (+) conditional branch· 180, 184 constant· 166 constant function' 219 constant pool· 173, 192, 194 constructor' 30, 32, 194 default· 30 Constructor' 96 Container' 121 ContainerEvent 130 continue' 61, 68 contract· 15 control falling-through· 65 control transfer' 61, 101 cut· 386,413 D data' 4, 5, 14 representation' 14 data persistence' 451 data structure' 141 Datalnput 86, 90, 102 DatalnputStream 86 DataOutput 86, 90, 102 DataOutputStream 86 default· 64 default value' 27 depth-first traversal, 293, 295,344, 365,370,383 deserialization 419 Dialog' 121 Dictionary' 142, 156 Digraph· 352,360,383 directed graph, 343, 344, 352, 383 directory· 88 distance' 344, 375, 383 document· 15, 58 dominance' 215 double' 59, 93 Double' 93 doubly linked list· 263, 268, 454 E edge' 343, 345 else' 64 entity' enumeration' 28, 276 Enumeration' 141,151,161 Error' 69 escape sequence' 59 event· 104, 125 Index class· 128 delegation' 103, 104, 125, 132 handler' 133 handling· 118, 119, 140 source' 125, 128 type' 132 EventObject· 125, 128 exception' 68-74, 195 checkable' 69, 101 handler' 69 handling· 57,68,69,72, 101 Exception 69 exception handler' 196 exponential function 219, 220 expression 61 extends' 33,42 extemalizability 419 Externalizable' 443,445,447,449, 451,463,467 F Fibonacci number' 189 Fibonaccian search, 253 field· 4, 5, 9, 26, 95 See also variable class' 26 instance' 10, 26 static' 27 Field· 93, 95 FIFO' 152,161 file 88 File' 88 file merge sort· 251 file sorting' 246 FileDescriptor' 88, 89 FileDialog' 121 FilelnputStream' 84,88,90 FileOutputStream' 85,88,90 File Writer' 245 final· 39 finally' 72 finally clause' 72 float· 6, 59, 93 Float· 93 flow' 387, 388 flow conservation' 387 flow layout· 122 FlowLayout· 122 FocusEvent· 129 for loop' 66 frame· 110, 194 Frame' 121,140 G garbage collection· 57, 192 goto' 184 graph, 343,344,345,383,451 Graph'346,348,356,383 graph serialization· 463 graphical operation' Ill, 113, 140 graphical user interface' See GUI graphics· 120 Graphics' Ill, 112, 114, 140 graphics attribute' Ill, 113, 120 GridBagLayout 122 GridLayout· 122 GUI· 103, 104, 117-36 H hash code' 156 Hashtable' 142, 157-59 heap' 193 heap sort· 239 height· 273 HTML·I05 I identifier' 59 if· 64 if statement· 63 ImageObserver' 119 implements' 42 import· 28 index' 142 inheritance' 32, 34, 55 hierarchy· 35 single' 45 initialization clause' 63 inner class' 96 101, 57, 102 inorder traversal, 293 InorderTraversal· 299 InputEvent· 129 InputStream 84 InputStreamReader 244 479 480 Index insertion sort· 231 instance· 25 creation· 30 instance field 204 instanceo!· 25 instruction· 176, 179, 199 instruction, Java Virtual Machine· 166, 176 int· 59,93 Integer· 93 interface· 42-45, 48, 55, 142 Internet· 57, 103, 140 Internet browser· 105 interpolation search· 254 interpreter· introspection· 93 ItemEvent 130 ItemSelectable· 121, 130 J Java compiler· Java interpreter· 109 Java language· 57 Java runtime system· 3,4, 191 Java stack· 194 Java Virtual Machine· 3, 165,201,203 java.applet 103 java.awt· 117, 121, 140 java.awt.event· 126, 128 java.io 84, 85 java lang 137 java lang reflect 94 javadoc· 16 javap·181 Just-in-time execution engine· 191, 200 K key· 142 KeyEvent 129 keyword· 59 L label· 67 Label· 121 layout border· 122 card· 123 flow· 110 grid· 123 layout manager· 117, 122, 125 LayoutAlanager· 122 LayoutAlanager2· 122 length· 345 leveled network· 385, 389 LeveledNetwork· 389,404,415 LIFO· 154,161 linear data structure· 451 linear search· 220 linearly linked list· 452 link· 268 linked list· 229, 230, 257, 268, 451 List· 121 listener· 119, 126, 130 listener interface· 126 literal· 59 load factor· 159 load operation· 179 local variable· 61, 62, 209 local variable array· 182, 194 local variable scope· 63 logarithmic function· 219 long· 59,93 Long· 93 M AI_aryTree 280 main method 109 m-ary tree· 271,279,342 Alath· 137,140 maximum flow· 385 member· 95 Alember· 93, 95 AlenuContainer· 119 merge sort· 234 message· 19 method· 3,4, 10, 14,55,94 abstract· 39 body· 12 class· 27 final· 39 instance· 27 main· name· 12 Index overloading· 21 overriding· 34 return type 12 static· 27 Method· 93,96, 138 method area· 193 method descriptor· 173 method invocation· 19,61,181,185, 210,211 minimum cut· 385,386,414,415 Modifier· 93 MouseAdapter· 115 MouseEvent· 129 MouseMotionAdapter· 115 multi-ary tree· 279 multithread programming· 57,74,101, 192 mutater 10 See also method N network· 385, 386 lVefiWork·389,390,391,415 new· 7,8 no-argument constructor· 168 node· 344 null· 12,60 lVumber·93 numeric conversion· 180 o object· 3,4-26 creation· 7, 10,94,203,205,211 Object· 33,55, 79,80,101 object graph· 420 object reflection· 57, 138 object serialization· 439 object stream· 422 ObjectlnputStream 440, 449 object-oriented analysis· 13 object-oriented program· 141 ObjectOutputStream 431, 434, 440, 449 ObjectStreamClass 430 opcode·176 operand stack· 186, 195 operation· 14,211 481 operator· 60 OutputStream· 84, 85 OutputStreamWriter·245 p package· 36,48, 79,96 unnamed· 36 Panel· 121 parameter· 12, 23 path· 273, 345 platform· 202 polymorphism· 45-47, 80 polynomial function· 219 postorder traversal· 293, 297, 365, 367, 371,383 PostorderTraversal· 301 PrefiowedlVefiWork·389,398,399,415 preorder traversal 293 PreorderTraversal· 298 presentation 111 primitive type 59, 178 private· See access mode problem size· 203 protected· See access mode public· See access mode PushbackInputStream 86 Q queue· 142,152-153,161 quick sort· 236 R Random· 104, 137, 140 RandomAccessFile· 88,90, 101 Reader· 244 recursion· 189,196,223,226 recursive algorithm· 223 recursive concept· 223 recursive equation· 224 reference· 5,6, reflection· 93-96, 102, 103 residual network· 385, 388 ResiduallVefiWork· 389,402,415 return· 12,19,61 482 Index return type 19 See also method root· 272 Runnable· 74, 75 See also thread RuntimeException 69 See also exception s Scrollbar· 121 ScrollPane 121 search· 230 selection sort· 232 semantic event· 130 serial representation· 419, 451 Serializable· 81, 119,440,449,467 serializable class· 436 serialization· 419,420,422,451,452, 456 serialized object· 426 short· 93 Short· 93 signature· 15 See also method simple instruction· 211 simple right rotation· 310 single-source distances problem· 375 singly linked list· 258,261 sink· 386 sorting algorithm· 230 source· 386 space· 201, 211 space complexity· 212, 225 stack· 161 Stack· 154-55 standard error output· 137 standard input· 13 standard output· 13 statement· 60 static· 26, 28, 96 static member class· 96 store operation 179 stream· 84 StreamTokenizer 244 String· 6, 81, 82,101 string concatenation· 81 string literal· 60 subclass· 33 subtree· 272 super· 59 superclass· 33, 79, 167 superinterface 42 switch statement· 185 switch value· 64 symbolic reference· 166, 173, 192 synchronized· 74, 78,101 System· 137, 140 T TextArea· 121 TextComponent· 121, 130 TextEvent 130 TextField· 121 this· 12, 19,20,59 thread· 74-79, 80,192,194 creation· 74 daemon· 74,77 priority· 74, 77 Thread· 74, 75 throw· 69, 71 throw statement· 71 throws· 68, 71 time· 201 time complexity· 212 token· 58 top-level class· 96 top-level window· 121 topological list 405 transient field· 441 tree· 271,342,451,456 Tree· 271,275 try· 72 type· 9,43,94, 141, 142, 193 primitive· 6, 25 type checking· 193 type descriptor· 172 u unconditional branch· 180 Unicode· 58, 59,171 uniform cost function· 201, 205, 206, 207,210,211,226 UtfS· 171, 172,426 v value Index primitive· 8,25 variable' 4, 5, 7, See also field class' 26 local' 7, 13 static' 26 vector' 161,229 Vector' 28,141,142, 147-51,229,428, 447 vector serialization' 428 vertex' 343, 383 void· 19 w wave algorithm· 385 483 weight· 343 weighted graph· 380 WeightedGraph 353, 361, 381, 382, 383 while loop' 67 white space' 58 Window' 121 WindowAdapter' 126, 133 WindowEvent· 130 WindowListener' 126, 130, 132, 133 word, 193 worst-case analysis' 212 Springer and the environment At Springer we fumly believe that an international science publisher has a special obligation to the environment, and our corporate policies consistently reflect this conviction We also expect our business partners paper mills, printers, packaging manufacturers, etc - to commit themselves to using materials and production processes that not harm the environment The paper in this book is made from low- or no-chlorine pulp and is acid free, in conformance with international standards for paper permanency Springer ... Index 477 Part I Java Programming - Data modeling in Java - The Java language - Programming in Java - Java data structure classes Chapter Data Modeling in Java Object technology for... application analysis and how to construct Java programs It presents the Java object model by studying a simplified supermarket It introduces the Java language and the standard Java data structures Graphics... concepts and how to apply the Java constructs for data modeling It presents the Java language and the Java standard data structure classes The fIrst part of the book consists of Chapters 1,2,3, and