Java Source Code
- Program 2.1
- Program to compute
.
- Program 2.2
- Program to compute
using Horner's rule.
- Program 2.3
- Recursive program to compute n!.
- Program 2.4
- Linear search to find
.
- Program 2.5
- Program to compute
.
- Program 2.6
- Program to compute
.
- Program 2.7
- Program to compute
using Horner's rule.
- Program 2.8
- Program to compute
.
- Program 2.9
- Program to compute
using the closed-form expression.
- Program 3.1
- Program 2.2 again.
- Program 3.2
- Program to compute
for
.
- Program 3.3
- Non-recursive program to compute Fibonacci numbers.
- Program 3.4
- Recursive program to compute Fibonacci numbers.
- Program 3.5
- Bucket sort.
- Program 4.1
- Array fields.
- Program 4.2
- Array constructors.
- Program 4.3
- Array class assign method.
- Program 4.4
- Array class accessor methods.
- Program 4.5
- Array class get and put methods.
- Program 4.6
- Array class setBase and setLength methods.
- Program 4.7
- MultiDimensionalArray fields.
- Program 4.8
- MultiDimensionalArray constructor.
- Program 4.9
- MultiDimensionalArray methods.
- Program 4.10
- Matrix interface.
- Program 4.11
- DenseMatrix fields and constructor.
- Program 4.12
- DenseMatrix class times method.
- Program 4.13
- LinkedList fields and LinkedList.Element class.
- Program 4.14
- LinkedList no-arg constructor.
- Program 4.15
- LinkedList class purge method.
- Program 4.16
- LinkedList class accessor methods.
- Program 4.17
- LinkedList class getFirst and getLast methods.
- Program 4.18
- LinkedList class prepend method.
- Program 4.19
- LinkedList class append method.
- Program 4.20
- LinkedList class constructor and assign methods.
- Program 4.21
- LinkedList class extract method.
- Program 4.22
- LinkedList.Element class insertAfter and insertBefore methods.
- Program 5.1
- Comparable interface.
- Program 5.2
- AbstractObject methods.
- Program 5.3
- AbstractObject class compare and compareTo methods.
- Program 5.4
- Chr class.
- Program 5.5
- Int class.
- Program 5.6
- Dbl class.
- Program 5.7
- Str class.
- Program 5.8
- Container interface.
- Program 5.9
- AbstractContainer fields and methods.
- Program 5.10
- Visitor interface.
- Program 5.11
- AbstractVisitor class.
- Program 5.12
- AbstractContainer class toString method.
- Program 5.13
- Enumeration interface.
- Program 5.14
- SearchableContainer interface.
- Program 5.15
- AbstractSearchableContainer class.
- Program 5.16
- Association fields.
- Program 5.17
- Association constructors.
- Program 5.18
- Association methods.
- Program 6.1
- Stack interface.
- Program 6.2
- StackAsArray fields.
- Program 6.3
- StackAsArray class constructor and purge methods.
- Program 6.4
- StackAsArray class push, pop, and getTop methods.
- Program 6.5
- StackAsArray class accept method.
- Program 6.6
- StackAsArray class getEnumeration method.
- Program 6.7
- StackAsLinkedList fields.
- Program 6.8
- StackAsLinkedList class constructor and purge methods.
- Program 6.9
- StackAsLinkedList class push, pop, and getTop methods.
- Program 6.10
- StackAsLinkedList class accept method.
- Program 6.11
- StackAsLinkedList class getEnumeration method.
- Program 6.12
- Stack application-a single-digit, RPN calculator.
- Program 6.13
- Queue interface.
- Program 6.14
- QueueAsArray fields.
- Program 6.15
- QueueAsArray constructor and purge methods.
- Program 6.16
- QueueAsArray class getHead, enqueue, and dequeue methods.
- Program 6.17
- QueueAsLinkedList fields.
- Program 6.18
- QueueAsLinkedList class constructor and purge methods.
- Program 6.19
- QueueAsLinkedList class enqueue, getHead and dequeue methods.
- Program 6.20
- Queue application-breadth-first tree traversal.
- Program 6.21
- Deque interface.
- Program 6.22
- DequeAsArray class ``Head'' methods.
- Program 6.23
- DequeAsArray class ``Tail'' methods.
- Program 6.24
- DequeAsLinkedList class ``Head'' methods.
- Program 6.25
- DequeAsLinkedList class ``Tail'' methods.
- Program 7.1
- OrderedList interface.
- Program 7.2
- Cursor interface.
- Program 7.3
- OrderedListAsArray fields.
- Program 7.4
- OrderedListAsArray class constructor and insert methods.
- Program 7.5
- OrderedListAsArray class isMember and find methods.
- Program 7.6
- OrderedListAsArray class withdraw method.
- Program 7.7
- OrderedListAsArray.MyCursor class.
- Program 7.8
- OrderedListAsArray class findPosition and get methods.
- Program 7.9
- OrderedListAsArray.MyCursor class insertAfter method.
- Program 7.10
- OrderedListAsArray.MyCursor class withdraw method.
- Program 7.11
- OrderedListAsLinkedList fields.
- Program 7.12
- OrderedListAsLinkedList class constructor, insert, and get methods.
- Program 7.13
- OrderedListAsLinkedList class isMember and find methods.
- Program 7.14
- OrderedListAsLinkedList class withdraw method.
- Program 7.15
- OrderedListAsLinkedList.MyCursor class.
- Program 7.16
- OrderedListAsLinkedList class findPosition method
- Program 7.17
- OrderedListAsLinkedList.MyCursor class insertAfter method.
- Program 7.18
- OrderedListAsLinkedList.MyCursor class withdraw method.
- Program 7.19
- Term class.
- Program 7.20
- Polynomial interface.
- Program 7.21
- PolynomialAsOrderedList class.
- Program 7.22
- SortedList interface.
- Program 7.23
- SortedListAsArray class.
- Program 7.24
- SortedListAsArray class insert method.
- Program 7.25
- SortedListAsArray class findOffset method.
- Program 7.26
- SortedListAsArray class find and findPosition methods.
- Program 7.27
- SortedListAsArray class withdraw method.
- Program 7.28
- SortedListAsLinkedList class.
- Program 7.29
- SortedListAsLinkedList class insert method.
- Program 7.30
- Term methods.
- Program 7.31
- PolynomialAsSortedList class plus method.
- Program 8.1
- Int class hashCode method.
- Program 8.2
- Dbl class hashCode method.
- Program 8.3
- Str class hashCode method.
- Program 8.4
- AbstractContainer class hashCode method.
- Program 8.5
- Association class hashCode method.
- Program 8.6
- HashTable interface.
- Program 8.7
- AbstractHashTable methods.
- Program 8.8
- ChainedHashTable fields.
- Program 8.9
- ChainedHashTable class constructor, getLength, and purge methods.
- Program 8.10
- ChainedHashTable class insert and withdraw methods.
- Program 8.11
- ChainedHashTable class find method.
- Program 8.12
- AbstractHashTable class getLoadFactor method.
- Program 8.13
- ChainedScatterTable fields and ChainedScatterTable.Entry class.
- Program 8.14
- ChainedScatterTable class constructor, getLength, and purge methods.
- Program 8.15
- ChainedScatterTable class insert and find methods.
- Program 8.16
- ChainedScatterTable class withdraw method.
- Program 8.17
- OpenScatterTable fields and OpenScatterTable.Entry class.
- Program 8.18
- OpenScatterTable class constructor, getLength, and purge methods.
- Program 8.19
- OpenScatterTable class c, findUnoccupied, and insert methods.
- Program 8.20
- OpenScatterTable Class findMatch and find methods.
- Program 8.21
- OpenScatterTable Class withdraw method.
- Program 8.22
- OpenScatterTableV2 withdraw method.
- Program 8.23
- Hash/scatter table application-counting words.
- Program 9.1
- Tree interface.
- Program 9.2
- AbstractTree class depthFirstTraversal method.
- Program 9.3
- PrePostVisitor interface.
- Program 9.4
- AbstractPrePostVisitor class.
- Program 9.5
- PreOrder class.
- Program 9.6
- InOrder class.
- Program 9.7
- PostOrder class.
- Program 9.8
- AbstractTree class breadthFirstTraversal method.
- Program 9.9
- AbstractTree class accept method.
- Program 9.10
- AbstractTree class getEnumeration method and the TreeEnumeration class.
- Program 9.11
- AbstractTree TreeEnumeration constructor.
- Program 9.12
- AbstractTree TreeEnumeration class hasMoreElements and nextElement methods.
- Program 9.13
- GeneralTree fields.
- Program 9.14
- GeneralTree class constructor and purge methods.
- Program 9.15
- GeneralTree class getKey, getSubtree, attachSubtreeand detachSubtree methods.
- Program 9.16
- NaryTree fields.
- Program 9.17
- NaryTree constructors.
- Program 9.18
- NaryTree methods.
- Program 9.19
- NaryTree methods.
- Program 9.20
- BinaryTree fields.
- Program 9.21
- BinaryTree constructors.
- Program 9.22
- BinaryTree class purge method.
- Program 9.23
- BinaryTree class depthFirstTraversal method.
- Program 9.24
- BinaryTree class compareTo method.
- Program 9.25
- Binary tree application-postfix to infix conversion.
- Program 9.26
- Binary tree application-printing infix expressions.
- Program 10.1
- SearchTree interface.
- Program 10.2
- BinarySearchTree class.
- Program 10.3
- BinarySearchTree class getLeftBST and getRightBST methods.
- Program 10.4
- BinarySearchTree class find and findMin methods.
- Program 10.5
- BinarySearchTree class insert, attachKey and balance methods.
- Program 10.6
- BinarySearchTree class withdraw method.
- Program 10.7
- AVLTree fields.
- Program 10.8
- AVLTree class constructor, getHeight, adjustHeight, and getBalanceFactor methods.
- Program 10.9
- AVLTree class doLLRotation method.
- Program 10.10
- AVLTree class doLRRotation method.
- Program 10.11
- AVLTree class balance method.
- Program 10.12
- AVLTree class attachKey method.
- Program 10.13
- AVLTree class detachKey method.
- Program 10.14
- MWayTree fields.
- Program 10.15
- MWayTree class depthFirstTraversal method.
- Program 10.16
- MWayTree class find method (linear search).
- Program 10.17
- MWayTree class findIndex and find methods (binary search).
- Program 10.18
- MWayTree class insert method.
- Program 10.19
- MWayTree class withdraw method.
- Program 10.20
- BTree fields.
- Program 10.21
- BTree class insert method.
- Program 10.22
- BTree class insertPair method.
- Program 10.23
- Application of search trees-word translation.
- Program 11.1
- PriorityQueue interface.
- Program 11.2
- MergeablePriorityQueue interface.
- Program 11.3
- BinaryHeap fields.
- Program 11.4
- BinaryHeap class constructor and purge methods.
- Program 11.5
- BinaryHeap class enqueue method.
- Program 11.6
- BinaryHeap class findMin method.
- Program 11.7
- BinaryHeap class dequeueMin method.
- Program 11.8
- LeftistHeap fields.
- Program 11.9
- LeftistHeap class merge method.
- Program 11.10
- LeftistHeap class enqueue method.
- Program 11.11
- LeftistHeap class findMin method.
- Program 11.12
- LeftistHeap class dequeueMin method.
- Program 11.13
- BinomialTree class.
- Program 11.14
- BinomialTree class add method.
- Program 11.15
- BinomialQueue fields.
- Program 11.16
- BinomialQueue class addTree and removeTree methods.
- Program 11.17
- BinomialQueue class findMinTree and findMin methods.
- Program 11.18
- BinomialQueue class merge method.
- Program 11.19
- BinomialQueue class sum and carry methods.
- Program 11.20
- BinomialQueue class enqueue method.
- Program 11.21
- BinomialQueue class dequeueMin method.
- Program 11.22
- Event class.
- Program 11.23
- Application of priority queues-discrete event simulation.
- Program 12.1
- Set interface.
- Program 12.2
- AbstractSet class.
- Program 12.3
- SetAsArray fields.
- Program 12.4
- SetAsArray class constructor, insert, withdraw, and isMember methods.
- Program 12.5
- SetAsArray class union, intersection and difference methods.
- Program 12.6
- SetAsArray class isEQ and isSubset methods.
- Program 12.7
- SetAsBitVector fields.
- Program 12.8
- SetAsBitVector class constructor, insert, withdraw, and isMember methods.
- Program 12.9
- SetAsBitVector class union, intersection and difference methods.
- Program 12.10
- Multiset interface.
- Program 12.11
- MultisetAsArray class.
- Program 12.12
- MultisetAsArray class constructor, insert, withdraw, and isMember methods.
- Program 12.13
- MultisetAsArray class union, intersection and difference methods.
- Program 12.14
- MultisetAsLinkedList fields.
- Program 12.15
- MultisetAsLinkedList class union method.
- Program 12.16
- MultisetAsLinkedList class intersection method.
- Program 12.17
- Partition interface.
- Program 12.18
- PartitionAsForest and PartitionTree fields.
- Program 12.19
- PartitionAsForest constructors.
- Program 12.20
- PartitionAsForest class find method.
- Program 12.21
- PartitionAsForest class simple join method.
- Program 12.22
- PartitionAsForest class collapsing find method.
- Program 12.23
- PartitionAsForest class union-by-size join method.
- Program 12.24
- PartitionAsForest class union-by-rank join method.
- Program 12.25
- Application of disjoint sets-finding equivalence classes.
- Program 14.1
- Solution interface.
- Program 14.2
- Solver interface.
- Program 14.3
- AbstractSolver class.
- Program 14.4
- DepthFirstSolver class.
- Program 14.5
- BreadthFirstSolver class.
- Program 14.6
- DepthFirstBranchAndBoundSolver class.
- Program 14.7
- Divide-and-conquer example-binary search.
- Program 14.8
- Divide-and-conquer Example-computing Fibonacci numbers.
- Program 14.9
- Divide-and-conquer example-merge sorting.
- Program 14.10
- Dynamic programming example-computing generalized Fibonacci numbers.
- Program 14.11
- Dynamic programming example-computing Binomial coefficients.
- Program 14.12
- Dynamic programming example-typesetting a paragraph.
- Program 14.13
- RandomNumberGenerator class.
- Program 14.14
- RandomVariable interface.
- Program 14.15
- SimpleRV class.
- Program 14.16
- UniformRV class.
- Program 14.17
- ExponentialRV class.
- Program 14.18
- Monte Carlo program to compute
.
- Program 15.1
- Sorter interface.
- Program 15.2
- AbstractSorter class.
- Program 15.3
- StraightInsertionSorter class sort method.
- Program 15.4
- BinaryInsertionSorter class sort method.
- Program 15.5
- BubbleSorter class sort method.
- Program 15.6
- AbstractQuickSorter fields.
- Program 15.7
- AbstractQuickSorter class recursive sort method.
- Program 15.8
- AbstractQuickSorter class sort method.
- Program 15.9
- MedianOfThreeQuickSorter class selectPivot method.
- Program 15.10
- StraightSelectionSorter class sort method.
- Program 15.11
- HeapSorter class percolateDown method.
- Program 15.12
- HeapSorter class buildHeap method.
- Program 15.13
- HeapSorter class sort method.
- Program 15.14
- TwoWayMergeSorter fields.
- Program 15.15
- TwoWayMergeSorter class merge method.
- Program 15.16
- TwoWayMergeSorter class sort methods.
- Program 15.17
- BucketSorter class constructor and sort methods.
- Program 15.18
- BucketSorter class sort method.
- Program 15.19
- RadixSorter fields.
- Program 15.20
- RadixSorter class sort method.
- Program 16.1
- Vertex interface.
- Program 16.2
- Edge interface.
- Program 16.3
- Graph interface.
- Program 16.4
- Digraph interface.
- Program 16.5
- AbstractGraph interface.
- Program 16.6
- GraphAsMatrix fields and constructor.
- Program 16.7
- GraphAsLists fields and constructor.
- Program 16.8
- AbstractGraph class depthFirstTraversal method.
- Program 16.9
- AbstractGraph class breadthFirstTraversal method.
- Program 16.10
- AbstractGraph class topologicalOrderTraversal method.
- Program 16.11
- AbstractGraph class isConnected method.
- Program 16.12
- AbstractGraph class isConnected method.
- Program 16.13
- AbstractGraph class isCyclic method.
- Program 16.14
- GraphAlgorithms Entry class.
- Program 16.15
- Dijkstra's algorithm.
- Program 16.16
- Floyd's algorithm.
- Program 16.17
- Prim's algorithm.
- Program 16.18
- Kruskal's algorithm.
- Program 16.19
- Critical path analysis-computing earliest event times.
- Program 16.20
- Critical path analysis-finding the critical paths.
- Program A.1
- Parameter passing example: passing primitive types.
- Program A.2
- Parameter passing example: passing reference types.
- Program A.3
- Complex class fields and methods.
- Program A.4
- Complex constructors.
- Program A.5
- Complex class accessor methods.
- Program A.6
- Complex class mutator methods.
- Program A.7
- Person class.
- Program A.8
- Parent class.
- Program A.9
- GraphicsPrimitives interface.
- Program A.10
- Point class.
- Program A.11
- GraphicalObject class.
- Program A.12
- Circle class.
- Program A.13
- Rectangle class.
- Program A.14
- Square class.
- Program A.15
- Using exceptions in Java.
Copyright © 1997 by
Bruno R. Preiss, P.Eng. All rights reserved.