dsap
- Code from the book Data Structures and Algorithms in Python.analysis
- Code from the chapter "Algorithm Analysis".disjoint
- Provides two functions for testing three-way set disjointness.exercises
- Provides code for end-of-chapter exercises.find
- Provides a find function, locating a value in a sequence.find_max
- Provides a find_max function locating the maximum value in a sequence.prefix_averages
- Provides three functions for computing prefix averages of a numeric sequence.unique
- Provides quadratic unique1 and n-log-n unique2 functions determining if a sequence contains duplicates.array
- Code from the chapter "Array-Based Sequences".caesar
- Provides a CaesarCipher class for encryption and decryption using a Caesar cipher.dynamic_array
- Provides a DynamicArray class built on first principles using low-level arraysexperiment_list_append
- Performs empirical testing of efficiency of list.append.experiment_list_size
- Performs empirical testing of dynamic resizing of a Python list.high_scores
- Provides GameEntry and Scoreboard class for a high-score board case study.insertion_sort
- Provides an implementation of insertion-sort for an array-based sequence.tic_tac_toe
- Provides a TicTacToe class demonstrating the representation of two-dimensional data.exceptions
- Provides a new "Empty" exception class used by a variety of the data structures.graph
- Code from the chapter "Graph Algorithms".bfs
- Provides BFS and BFS_complete function to support breadth-first search of a graph.dfs
- Provides DFS, DFS_complete, and construct_path functions for depth-first search of a graph.graph
- Provides Graph class and nested Vertex and Edge classes for representing a graph structure.graph_examples
- Provides graph instances used in the book's examples.mst
- Provides MST_PrimJarnik and MST_Kruskal functions for computing the minimum spanning tree of a graph.partition
- Provides the Partition class maintaining a disjoint partition of a universe of elements.shortest_paths
- Provides shortest_path_distances and shortest_path_tree functions for computing shortest paths in a weighted graph.topological_sort
- Provides topological_sort function that computes a topological order for a directed acyclic graphtransitive_closure
- Provides floyd_warshall function for computing the transitive closure of a graph.linkedlist
- Code from the chapter "Linked Lists".circular_queue
- Provides the LinkedCircularqueue class implementing a queue with a circularly linked list.doubly_linked_base
- Provides the _DoublyLinkedBase class providing an underling doubly linked list representation.favorites_list
- Provides the FavoritesList class maintaining a list of elements ordered by access frequency.favorites_list_mtf
- Provides the FavoritesListMTF class maintaining a list of elements ordered by most-recent access.insertion_sort_positional
- Provides insertion_sort function that sorts a PositionalList.linked_deque
- Provides the LinkedDeque class implementing a double-ended queue with a linked list.linked_queue
- Provides the LinkedQueue class implementing a FIFO queue with a singly linked list.linked_stack
- Provides the LinkedStack class implementing a stack with a singly linked list.positional_list
- Provides the PositionalList class providing a position-based abstraction of a sequence.mapping
- Code from the chapter "Maps, Hash Tables, and Skip Lists".chain_hash_map
- Provides the ChainHashMap class implementing a map using hashing with separate chaining.cost_performance
- Provides the CostPerformanceDatabase class demonstrating a use case for a sorted map.hash_map_base
- Provides the HashMapBase class used by several concrete map implementations.map_base
- Provides the MapBase class used by various concrete map implementations.multi_map
- Provides the MultiMap class demonstrating an adaptation of a standard map.probe_hash_map
- Provides the ProbeHashMap implementing a map using hashing with linear probing.sorted_table_map
- Provides a SortedTableMap class implementing the sorted map ADT.unsorted_table_map
- Provides the UnsortedTableMap class implementing a simple map.word_frequency
- A case study computing word frequencies within a text document.oop
- Code from the chapter "Object-Oriented Programming".credit_card
- Provides the CreditCard class as an example of a class definition.our_range
- Provides the OurRange class which mimics the built-in range class.predatory_credit_card
- Provides the PredatoryCreditCard class as an example of inheritance.progressions
- Provides the Progression class that serves as a base class for several other classes.sequence_abc
- Provides the Sequence class as an example of a abstract base class.sequence_iterator
- Provides the SequenceIterator class as an example of a Python iterator.vector
- Provides the Vector class representing multidimensional coordinates.pq
- Code from the chapter "Priority Queues".adaptable_heap_priority_queue
- Provides the AdaptableHeapPriorityQueue class.heap_priority_queue
- Provides the HeapPriorityQueue class.priority_queue_base
- Provides the PriorityQueueBase class that is used by several concrete priority queue implementations.sorted_priority_queue
- Provides the SortedPriorityQueue class.unsorted_priority_queue
- Provides the UnsortedPriorityQueue class.primer
- Code from the chapter "Python Primer".age1
- Demonstrates a try/except clause involving user input.age2
- Demonstrates a try/except clause with two different except clauses.contains
- Provides a simple function contains(data,target).count
- Provides a simple function count(data,target).factors1
- Provides a simple function factors(n) that returns list of factors of integer.factors2
- Provides a simple function factors(n) that returns a generator of factors of integer.factors3
- Provides a simple function factors(n) that returns a generator of factors of integer.fibonacci1
- Provides a simple function fibonacci() that generates the infinite Fibonacci series.fibonacci2
- Provides a simple function fibonacci() that generates the infinite Fibonacci series.gpa1
- A demonstration of a complete script, computing the GPA based on grades input by the user.gpa2
- Provides a compute_gpa function to compute the GPA based on a sequence of grades sent as a parameter.heartrate
- A simple demonstration of a complete script, computing the ideal maximum heart rate based on input from a user.range
- An incomplete implementation of a range(start,stop,step) function demonstrating use of default parameters.scale
- Provides a simple scale(data,factor) function.sum1
- Provides a simple function sum(values) that includes rigorous error checking.sum2
- Provides a simple function sum(values) to compute the sum of a sequence of numbers.recursion
- Code from the chapter "Recursion".binary_search
- Provides recursive binary_search function.binary_search_iterative
- Provides iterative binary_search_iterative function.binary_sum
- Provides recursive function binary_sum computing the sum of a sequence of numbers.disk_usage
- Provides recursive disk_usage(path) function, computing the number of bytes used by a file/folder.factorial
- Provides recursive factorial(n) function.fibonacci
- Provides recursive functions bad_fibonacci and good_fibonacci.linear_sum
- Provides recursive function linear_sum(S,n) that returns sum of first n numbers of sequence S.power_fast
- Provides recursive function power(x,n) that uses repeated squaring technique.power_slow
- Provides recursive function power(x,n) that uses a linear recursion.reverse
- Provides recursive function to reverse elements of a sequence.reverse_iterative
- Provides iterative function to reverse elements of a sequence.ruler
- Provides draw_ruler function, and utilities draw_line and draw_interval, for displaying an English ruler.unique_bad
- Provides an inefficient recursive algorithm unique3, for testing if a sequence contains duplicates.searchtree
- Code from the chapter "Search Trees".avl_tree
- Provides the AVLTreeMap class implementing a map using an AVL tree.binary_search_tree
- Provides the TreeMap class implementing a map using an (unbalanced) binary search tree.red_black_tree
- Provides the RedBlackTreeMap class implementing a map using a red-black tree.splay_tree
- Provides the SplayTreeMap class implementing a map using a splay tree.sorting
- Code from the chapter "Sorting and Selection".decorated_merge_sort
- Provides a demonstration of the decorate-sort-undecorate pattern as a decorated_merge_sort function.merge_array
- Provides recursive merge-sort implementation for array-based sequence, in form of merge_sort function and merge utility function.merge_nonrecur
- Provides bottom-up iterative merge-sort implementation as merge_sort function and merge utility function.merge_queue
- Provides bottom-up iterative merge-sort implementation for elements from a queue.quick_inplace
- Provides in-place implementation of quick-sort for elements in an array-based sequence.quick_queue
- Provides the quick_sort function implementing quick-sort on elements from a FIFO queue.quick_select
- Provides the quick_select function to perform randomized selection in linear time.stackqueue
- Code from the chapter "Stacks, Queues, and Deques".array_queue
- Provides the ArrayQueue class implementing a queue with an array-based sequence.array_stack
- Basic example of an adapter class to provide a stack interface to Python's list.match_delimiters
- Provides is_matched function as a use case for a stack.match_html
- Provides is_matched_html function as use case for a stack.reverse_file
- Provides reverse_file function as use case for a stack.text
- Code from the chapter "Text Processing".find_boyer_moore
- Provides the find_boyer_moore function to perform a text search using the Boyer-Moore algorithm.find_brute
- Provides the find_brute to perform a text search using the brute-force algorithm.find_kmp
- Provides the find_kmp function and compute_kmp_fail utility to perform a text search using the Knuth-Morris-Pratt algorithm.lcs
- Provides the LCS and LCS_solution functions computing a longest-common substring of two strings.matrix_chain
- Provides matrix_chain function as an example of dynamic programming.trees
- Code from the chapter "Trees".binary_tree
- Provides the BinaryTree class as an abstract base class for the binary tree ADT.euler_tour
- Provides the EulerTour class that mechanizes an Euler tour.euler_tour_examples
- Provides several example applications as subclasses of the EulerTour class.expression_tree
- Provides the ExpressionTree class as a use case of a specialized tree.linked_binary_tree
- Provides the LinkedBinaryTree class providing a node-based representation of a binary tree.traversal_examples
- Provides several example applications for tree traversals.tree
- Provides the Tree class as an abstract base class for the Tree ADT.