Python 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 class __init__ method.
- Program 4.2
- Array class __copy__ method.
- Program 4.3
- Array class __getitem__ and __setitem__ methods.
- Program 4.4
- Array class data and baseIndex properties.
- Program 4.5
- Array class length property.
- Program 4.6
- MultiDimensionalArray class __init__ method.
- Program 4.7
- MultiDimensionalArray class __getitem__ and __setitem__ methods.
- Program 4.8
- Matrix class.
- Program 4.9
- DenseMatrix class __init__, __getitem__ and __setitem__ methods.
- Program 4.10
- DenseMatrix class __times__ method.
- Program 4.11
- LinkedList.Element class.
- Program 4.12
- LinkedList class __init__ method.
- Program 4.13
- LinkedList class purge method.
- Program 4.14
- LinkedList class properties.
- Program 4.15
- LinkedList class first and last properties.
- Program 4.16
- LinkedList class prepend method.
- Program 4.17
- LinkedList class append method.
- Program 4.18
- LinkedList class __copy__ method.
- Program 4.19
- LinkedList class extract method.
- Program 4.20
- LinkedList.Element class insertAfter and insertBefore methods.
- Program 5.1
- Object class definition.
- Program 5.2
- abstractmethod class definition.
- Program 5.3
- Container class.
- Program 5.4
- Container methods and properties.
- Program 5.5
- Iterator class.
- Program 5.6
- Visitor interface.
- Program 5.7
- Container class accept method.
- Program 5.8
- Container class __str__ method.
- Program 5.9
- SearchableContainer abstract class.
- Program 5.10
- Association class __init__ method.
- Program 5.11
- Association properties.
- Program 5.12
- Association methods.
- Program 6.1
- Abstract Stack class.
- Program 6.2
- StackAsArray __init__ and purge methods.
- Program 6.3
- StackAsArray class push, pop, and getTop methods.
- Program 6.4
- StackAsArray class accept method.
- Program 6.5
- StackAsArray class __iter__ method.
- Program 6.6
- StackAsLinkedList __init__ and purge methods.
- Program 6.7
- StackAsLinkedList class push, pop and getTop methods.
- Program 6.8
- StackAsLinkedList class accept method.
- Program 6.9
- StackAsLinkedList class __iter__ method.
- Program 6.10
- Stack application-a single-digit, RPN calculator.
- Program 6.11
- Abstract Queue class.
- Program 6.12
- QueueAsArray __init__ and purge methods.
- Program 6.13
- QueueAsArray class enqueue, Dequeue and getHead methods.
- Program 6.14
- QueueAsLinkedList class __init__ and purge methods.
- Program 6.15
- QueueAsLinkedList class enqueue, dequeue and getHead methods.
- Program 6.16
- Queue application-breadth-first tree traversal.
- Program 6.17
- Abstract Deque class.
- Program 6.18
- DequeAsArray class enqueueHead method.
- Program 6.19
- DequeAsArray class dequeueTail and getTail methods.
- Program 6.20
- DequeAsLinkedList class enqueueHead method.
- Program 6.21
- DequeAsLinkedList class dequeueTail and getTail methods.
- Program 7.1
- Abstract OrderedList class.
- Program 7.2
- Abstract Cursor class.
- Program 7.3
- OrderedListAsArray class __init__ method.
- Program 7.4
- OrderedListAsArray class insert method.
- Program 7.5
- OrderedListAsArray class __contains__ and find methods.
- Program 7.6
- OrderedListAsArray class withdraw method.
- Program 7.7
- OrderedListAsArray.Cursor class __init__ and getDatum methods.
- Program 7.8
- OrderedListAsArray class findPosition and and __getitem__ methods.
- Program 7.9
- OrderedListAsArray.Cursor class insertAfter method.
- Program 7.10
- OrderedListAsArray.Cursor class withdraw method.
- Program 7.11
- OrderedListAsLinkedList class __init__ method.
- Program 7.12
- OrderedListAsLinkedList class insert and __getitem__ methods.
- Program 7.13
- OrderedListAsLinkedList class __contains__ and find methods.
- Program 7.14
- OrderedListAsLinkedList class withdraw method.
- Program 7.15
- OrderedListAsLinkedList.Cursor class __init__ and getDatum methods.
- Program 7.16
- OrderedListAsLinkedList class findPosition method
- Program 7.17
- OrderedListAsLinkedList.Cursor class insertAfter method.
- Program 7.18
- OrderedListAsLinkedList.Cursor class withdraw method.
- Program 7.19
- Polynomial.Term class.
- Program 7.20
- Abstract Polynomial class.
- Program 7.21
- PolynomialAsOrderedList class.
- Program 7.22
- Polynomial class differentiate method.
- Program 7.23
- Abstract SortedList class.
- Program 7.24
- SortedListAsArray class.
- Program 7.25
- SortedListAsArray class insert method.
- Program 7.26
- SortedListAsArray class findOffset method.
- Program 7.27
- SortedListAsArray class find and findPosition methods.
- Program 7.28
- SortedListAsArray class withdraw method.
- Program 7.29
- SortedListAsLinkedList class.
- Program 7.30
- SortedListAsLinkedList class insert method.
- Program 7.31
- Term methods.
- Program 7.32
- PolynomialAsSortedList class __init__ and __add__ methods.
- Program 8.1
- Integer class __hash__ method.
- Program 8.2
- Float class __hash__ method.
- Program 8.3
- String class __hash__ method.
- Program 8.4
- Container class __hash__ method.
- Program 8.5
- Association class __hash__ method.
- Program 8.6
- Abstract HashTable class.
- Program 8.7
- Abstract HashTable class f, g and h methods.
- Program 8.8
- ChainedHashTable class __init__, __len__ and purge methods.
- Program 8.9
- ChainedHashTable class insert and withdraw methods.
- Program 8.10
- ChainedHashTable class find method.
- Program 8.11
- ChainedScatterTable.Entry class __init__ method.
- Program 8.12
- ChainedScatterTable class __init__, __len__ and purge methods.
- Program 8.13
- ChainedScatterTable class insert and find methods.
- Program 8.14
- ChainedScatterTable class withdraw method.
- Program 8.15
- OpenScatterTable.Entry class __init__ method.
- Program 8.16
- OpenScatterTable class __init__, __len__ and purge methods.
- Program 8.17
- OpenScatterTable class c, findUnoccupied and insert methods.
- Program 8.18
- OpenScatterTable class findMatch and find methods.
- Program 8.19
- OpenScatterTable Class withdraw method.
- Program 8.20
- OpenScatterTableV2 class withdraw method.
- Program 8.21
- Hash/scatter table application-counting words.
- Program 9.1
- Abstract Tree class.
- Program 9.2
- Abstract Tree class depthFirstTraversal method.
- Program 9.3
- PrePostVisitor class.
- Program 9.4
- PreOrder class.
- Program 9.5
- InOrder class.
- Program 9.6
- PostOrder class.
- Program 9.7
- Abstract Tree class breadthFirstTraversal method.
- Program 9.8
- Abstract Tree class accept method.
- Program 9.9
- Abstract Tree class __iter__ method and the Tree.Iterator class.
- Program 9.10
- GeneralTree class __init__ and purge methods.
- Program 9.11
- GeneralTree class getKey, getSubtree, attachSubtree and detachSubtree methods.
- Program 9.12
- NaryTree class __init__ and purge methods.
- Program 9.13
- NaryTree class getKey, getIsEmpty, attachKey and detachKey methods.
- Program 9.14
- NaryTree class getSubtree, attachSubtree and detachSubtree methods.
- Program 9.15
- BinaryTree class __init__ and purge methods.
- Program 9.16
- BinaryTree left and right properties
- Program 9.17
- BinaryTree class DepthFirstTraversal method.
- Program 9.18
- BinaryTree class CompareTo method.
- Program 9.19
- Binary tree application-postfix to infix conversion.
- Program 9.20
- Binary tree application-printing infix expressions.
- Program 10.1
- Abstract SearchTree class min and max properties.
- Program 10.2
- BinarySearchTree class __init__ method.
- Program 10.3
- BinarySearchTree class find and getMin methods.
- Program 10.4
- BinarySearchTree class insert, attachKey and balance methods.
- Program 10.5
- BinarySearchTree class withdraw method.
- Program 10.6
- AVLTree class __init__ method.
- Program 10.7
- AVLTree class adjustHeight and getHeight methods and balanceFactor property.
- Program 10.8
- AVLTree class doLLRotation method.
- Program 10.9
- AVLTree class doLRRotation method.
- Program 10.10
- AVLTree class balance method.
- Program 10.11
- AVLTree class attachKey method.
- Program 10.12
- AVLTree class detachKey method.
- Program 10.13
- MWayTree class __init__ method and m property
- Program 10.14
- MWayTree class depthFirstTraversal method.
- Program 10.15
- MWayTree class find method (linear search).
- Program 10.16
- MWayTree class findIndex and find methods (binary search).
- Program 10.17
- MWayTree class insert method.
- Program 10.18
- MWayTree class withdraw method.
- Program 10.19
- BTree class __init__ and attachSubtree methods.
- Program 10.20
- BTree class insert method.
- Program 10.21
- BTree class insertUp method.
- Program 10.22
- Application of search trees-word translation.
- Program 11.1
- Abstract PriorityQueue class.
- Program 11.2
- Abstract MergeablePriorityQueue class.
- Program 11.3
- BinaryHeap class __init__ and purge methods.
- Program 11.4
- BinaryHeap class enqueue method.
- Program 11.5
- BinaryHeap class getMin method.
- Program 11.6
- BinaryHeap class dequeueMin method.
- Program 11.7
- LeftistHeap class __init__ method.
- Program 11.8
- LeftistHeap class merge method.
- Program 11.9
- LeftistHeap class enqueue method.
- Program 11.10
- LeftistHeap class getMin method.
- Program 11.11
- LeftistHeap class dequeueMin method.
- Program 11.12
- BinomialQueue.BinomialTree class __init__ method.
- Program 11.13
- BinomialTree class add method.
- Program 11.14
- BinomialQueue class __init__ method.
- Program 11.15
- BinomialQueue class addTree and removeTree methods.
- Program 11.16
- BinomialQueue class getMinTree and getMin methods.
- Program 11.17
- BinomialQueue class merge method.
- Program 11.18
- BinomialQueue class fullAdder method.
- Program 11.19
- BinomialQueue class enqueue method.
- Program 11.20
- BinomialQueue class dequeueMin method.
- Program 11.21
- Simulation.Event class.
- Program 11.22
- Application of priority queues-discrete event simulation.
- Program 12.1
- Abstract Set class.
- Program 12.2
- SetAsArray class __init__ method.
- Program 12.3
- SetAsArray class insert, __contains__ and withdraw methods.
- Program 12.4
- SetAsArray class __or__, __and__ and __sub__ methods.
- Program 12.5
- SetAsArray class __eq__ and __lt__ methods.
- Program 12.6
- SetAsBitVector class __init__ method.
- Program 12.7
- SetAsBitVector insert, __contains__ and withdraw methods.
- Program 12.8
- SetAsBitVector class __or__, __and__ and __sub__ methods.
- Program 12.9
- Abstract Multiset class.
- Program 12.10
- MultisetAsArray class __init__ method.
- Program 12.11
- MultisetAsArray class insert, __contains__ and withdraw methods.
- Program 12.12
- MultisetAsArray class __or__, __and__ and __sub__ methods.
- Program 12.13
- MultisetAsLinkedList class __init__ method.
- Program 12.14
- MultisetAsLinkedList class __or__ method.
- Program 12.15
- MultisetAsLinkedList class __and__ method.
- Program 12.16
- Abstract Partition class.
- Program 12.17
- PartitionAsForest.PartitionTree class __init__ method.
- Program 12.18
- PartitionAsForest class __init__ method.
- Program 12.19
- PartitionAsForest class find method.
- Program 12.20
- PartitionAsForest class simple join method.
- Program 12.21
- PartitionAsForest class collapsing find method.
- Program 12.22
- PartitionAsForest class union-by-size join method.
- Program 12.23
- PartitionAsForest class union-by-rank join method.
- Program 12.24
- Application of disjoint sets-finding equivalence classes.
- Program 14.1
- Abstract Solution class.
- Program 14.2
- Abstract Solver class.
- Program 14.3
- DepthFirstSolver class __init__ and search methods.
- Program 14.4
- BreadthFirstSolver class __init__ and search methods.
- Program 14.5
- DepthFirstBranchAndBoundSolver class __init__ and search methods.
- Program 14.6
- Divide-and-conquer example-binary search.
- Program 14.7
- Divide-and-conquer Example-computing Fibonacci numbers.
- Program 14.8
- Divide-and-conquer example-merge sorting.
- Program 14.9
- Dynamic programming example-computing generalized Fibonacci numbers.
- Program 14.10
- Dynamic programming example-computing Binomial coefficients.
- Program 14.11
- Dynamic programming example-typesetting a paragraph.
- Program 14.12
- RandomNumberGenerator class __init__ method, and __seed__ and next properties.
- Program 14.13
- Abstract RandomVariable class.
- Program 14.14
- SimpleRV class.
- Program 14.15
- UniformRV class.
- Program 14.16
- ExponentialRV class.
- Program 14.17
- Monte Carlo program to compute
.
- Program 15.1
- Abstract Sorter class.
- Program 15.2
- StraightInsertionSorter class __init__ and _sort methods.
- Program 15.3
- BinaryInsertionSorter class __init__ and _sort methods.
- Program 15.4
- BubbleSorter class __init__ and _sort methods.
- Program 15.5
- Abstract QuickSorter class __init__ and selectPivot methods.
- Program 15.6
- Abstract QuickSorter class quicksort method.
- Program 15.7
- Abstract QuickSorter class _sort method.
- Program 15.8
- MedianOfThreeQuickSorter class __init__ and selectPivot methods.
- Program 15.9
- StraightSelectionSorter class __init__ and _sort methods.
- Program 15.10
- HeapSorter class __init__ and percolateDown methods.
- Program 15.11
- HeapSorter class buildHeap method.
- Program 15.12
- HeapSorter class _sort method.
- Program 15.13
- TwoWayMergeSorter __init__ method.
- Program 15.14
- TwoWayMergeSorter class merge method.
- Program 15.15
- TwoWayMergeSorter class _sort and mergesort methods.
- Program 15.16
- BucketSorter class __init__ method.
- Program 15.17
- BucketSorter class _sort method.
- Program 15.18
- RadixSorter class __init__ method.
- Program 15.19
- RadixSorter class _sort method.
- Program 16.1
- Abstract Vertex class.
- Program 16.2
- Abstract Edge class.
- Program 16.3
- Abstract Graph, Graph.Vertex and Graph.Edge __init__ methods.
- Program 16.4
- Abstract Graph class properties.
- Program 16.5
- Abstract Graph class accessors and mutators.
- Program 16.6
- Abstract Digraph class.
- Program 16.7
- GraphAsMatrix class __init__ method.
- Program 16.8
- GraphAsLists class __init__ method.
- Program 16.9
- Abstract Graph class depthFirstTraversal method.
- Program 16.10
- Abstract Graph class breadthFirstTraversal method.
- Program 16.11
- Abstract Digraph class topologicalOrderTraversal method.
- Program 16.12
- Abstract Graph class getIsConnected method.
- Program 16.13
- Abstract Digraph class getIsConnected method.
- Program 16.14
- Abstract Digraph class getIsCyclic method.
- Program 16.15
- Algorithms.Entry class __init__ method.
- Program 16.16
- Dijkstra's algorithm.
- Program 16.17
- Floyd's algorithm.
- Program 16.18
- Prim's algorithm.
- Program 16.19
- Kruskal's algorithm.
- Program 16.20
- Critical path analysis-computing earliest event times.
- Program 16.21
- Critical path analysis-finding the critical paths.
- Program A.1
- Example of parameter passing.
- Program A.2
- Complex class __init__ method.
- Program A.3
- Complex class real and imag properties.
- Program A.4
- Complex class r and theta properties.
- Program A.5
- Complex class __add__, __sub__ and __mul__ methods.
- Program A.6
- Complex class __main__ method.
- Program A.7
- Person class.
- Program A.8
- Parent class.
- Program A.9
- GraphicalObject class __init__, draw, erase and moveTo methods.
- Program A.10
- Point class __init__ method.
- Program A.11
- Circle class.
- Program A.12
- Rectangle class.
- Program A.13
- Square class.
- Program A.14
- Using exceptions in Python.
Copyright © 2003 by
Bruno R. Preiss, P.Eng. All rights reserved.