You are on page 1of 6

Problem Solving with Algorithms and Data Structures using Python

6/11/17,
... 6:32 PM

Problem Solving with Algorithms and


Data Structures using Python

By Brad Miller and David Ranum, Luther College

Assignments (assignments.html)

1. Introduction (Introduction/toctree.html)
1.1. Objectives (Introduction/Objectives.html)
1.2. Getting Started (Introduction/GettingStarted.html)
1.3. What Is Computer Science? (Introduction/WhatIsComputerScience.html)
1.4. What Is Programming? (Introduction/WhatIsProgramming.html)
1.5. Why Study Data Structures and Abstract Data Types?
(Introduction/WhyStudyDataStructuresandAbstractDataTypes.html)
1.6. Why Study Algorithms? (Introduction/WhyStudyAlgorithms.html)
1.7. Review of Basic Python (Introduction/Review of BasicPython.html)
1.8. Getting Started w ith Data (Introduction/GettingStartedw ithData.html)
1.8.1. Built-in Atomic Data Types (Introduction/GettingStartedw ithData.html#built-in-
atomic-data-types)
1.8.2. Built-in Collection Data Types (Introduction/GettingStartedw ithData.html#built-in-
collection-data-types)
1.9. Input and Output (Introduction/InputandOutput.html)
1.9.1. String Formatting (Introduction/InputandOutput.html#string-f ormatting)
1.10. Control Structures (Introduction/ControlStructures.html)
1.11. Exception Handling (Introduction/ExceptionHandling.html)
1.12. Def ining Functions (Introduction/Def iningFunctions.html)
1.13. Object-Oriented Programming in Python: Def ining Classes
(Introduction/ObjectOrientedProgramminginPythonDef iningClasses.html)
1.13.1. A Fraction Class
(Introduction/ObjectOrientedProgramminginPythonDef iningClasses.html#a-f raction-
class)
1.13.2. Inheritance: Logic Gates and Circuits
(Introduction/ObjectOrientedProgramminginPythonDef iningClasses.html#inheritance-
logic-gates-and-circuits)
1.14. Summary (Introduction/Summary.html)
1.15. Key Terms (Introduction/KeyTerms.html)
1.16. Discussion Questions (Introduction/DiscussionQuestions.html)

1 of 6
Problem Solving with Algorithms and Data Structures using Python
6/11/17,
... 6:32 PM

1.17. Programming Exercises (Introduction/ProgrammingExercises.html)


2. Analysis (AlgorithmAnalysis/toctree.html)
2.1. Objectives (AlgorithmAnalysis/Objectives.html)
2.2. What Is Algorithm Analysis? (AlgorithmAnalysis/WhatIsAlgorithmAnalysis.html)
2.3. Big-O Notation (AlgorithmAnalysis/BigONotation.html)
2.4. An Anagram Detection Example (AlgorithmAnalysis/AnAnagramDetectionExample.html)
2.4.1. Solution 1: Checking Off
(AlgorithmAnalysis/AnAnagramDetectionExample.html#solution-1-checking-off )
2.4.2. Solution 2: Sort and Compare
(AlgorithmAnalysis/AnAnagramDetectionExample.html#solution-2-sort-and-compare)
2.4.3. Solution 3: Brute Force
(AlgorithmAnalysis/AnAnagramDetectionExample.html#solution-3-brute-f orce)
2.4.4. Solution 4: Count and Compare
(AlgorithmAnalysis/AnAnagramDetectionExample.html#solution-4-count-and-
compare)
2.5. Perf ormance of Python Data Structures
(AlgorithmAnalysis/Perf ormanceof PythonDataStructures.html)
2.6. Lists (AlgorithmAnalysis/Lists.html)
2.7. Dictionaries (AlgorithmAnalysis/Dictionaries.html)
2.8. Summary (AlgorithmAnalysis/Summary.html)
2.9. Key Terms (AlgorithmAnalysis/KeyTerms.html)
2.10. Discussion Questions (AlgorithmAnalysis/DiscussionQuestions.html)
2.11. Programming Exercises (AlgorithmAnalysis/ProgrammingExercises.html)
3. Basic Data Structures (BasicDS/toctree.html)
3.1. Objectives (BasicDS/Objectives.html)
3.2. What Are Linear Structures? (BasicDS/WhatAreLinearStructures.html)
3.3. What is a Stack? (BasicDS/WhatisaStack.html)
3.4. The Stack Abstract Data Type (BasicDS/TheStackAbstractDataType.html)
3.5. Implementing a Stack in Python (BasicDS/ImplementingaStackinPython.html)
3.6. Simple Balanced Parentheses (BasicDS/SimpleBalancedParentheses.html)
3.7. Balanced Symbols (A General Case) (BasicDS/BalancedSymbols(AGeneralCase).html)
3.8. Converting Decimal Numbers to Binary Numbers
(BasicDS/ConvertingDecimalNumberstoBinaryNumbers.html)
3.9. Inf ix, Pref ix and Postf ix Expressions (BasicDS/Inf ixPref ixandPostf ixExpressions.html)
3.9.1. Conversion of Inf ix Expressions to Pref ix and Postf ix
(BasicDS/Inf ixPref ixandPostf ixExpressions.html#conversion-of -inf ix-expressions-to-
pref ix-and-postf ix)
3.9.2. General Inf ix-to-Postf ix Conversion
(BasicDS/Inf ixPref ixandPostf ixExpressions.html#general-inf ix-to-postf ix-conversion)
3.9.3. Postf ix Evaluation (BasicDS/Inf ixPref ixandPostf ixExpressions.html#postf ix-
evaluation)
3.10. What Is a Queue? (BasicDS/WhatIsaQueue.html)
3.11. The Queue Abstract Data Type (BasicDS/TheQueueAbstractDataType.html)
3.12. Implementing a Queue in Python (BasicDS/ImplementingaQueueinPython.html)
3.13. Simulation: Hot Potato (BasicDS/SimulationHotPotato.html)
3.14. Simulation: Printing Tasks (BasicDS/SimulationPrintingTasks.html)
3.14.1. Main Simulation Steps (BasicDS/SimulationPrintingTasks.html#main-simulation-
steps)

2 of 6
Problem Solving with Algorithms and Data Structures using Python
6/11/17,
... 6:32 PM

3.14.2. Python Implementation (BasicDS/SimulationPrintingTasks.html#python-


implementation)
3.14.3. Discussion (BasicDS/SimulationPrintingTasks.html#discussion)
3.15. What Is a Deque? (BasicDS/WhatIsaDeque.html)
3.16. The Deque Abstract Data Type (BasicDS/TheDequeAbstractDataType.html)
3.17. Implementing a Deque in Python (BasicDS/ImplementingaDequeinPython.html)
3.18. Palindrome-Checker (BasicDS/PalindromeChecker.html)
3.19. Lists (BasicDS/Lists.html)
3.20. The Unordered List Abstract Data Type
(BasicDS/TheUnorderedListAbstractDataType.html)
3.21. Implementing an Unordered List: Linked Lists
(BasicDS/ImplementinganUnorderedListLinkedLists.html)
3.21.1. The Node Class (BasicDS/ImplementinganUnorderedListLinkedLists.html#the-
node-class)
3.21.2. The Unordered List Class
(BasicDS/ImplementinganUnorderedListLinkedLists.html#the-unordered-list-class)
3.22. The Ordered List Abstract Data Type
(BasicDS/TheOrderedListAbstractDataType.html)
3.23. Implementing an Ordered List (BasicDS/ImplementinganOrderedList.html)
3.23.1. Analysis of Linked Lists (BasicDS/ImplementinganOrderedList.html#analysis-
of -linked-lists)
3.24. Summary (BasicDS/Summary.html)
3.25. Key Terms (BasicDS/KeyTerms.html)
3.26. Discussion Questions (BasicDS/DiscussionQuestions.html)
3.27. Programming Exercises (BasicDS/ProgrammingExercises.html)
4. Recursion (Recursion/toctree.html)
4.1. Objectives (Recursion/Objectives.html)
4.2. What Is Recursion? (Recursion/WhatIsRecursion.html)
4.3. Calculating the Sum of a List of Numbers
(Recursion/pythondsCalculatingtheSumof aListof Numbers.html)
4.4. The Three Law s of Recursion (Recursion/TheThreeLaw sof Recursion.html)
4.5. Converting an Integer to a String in Any Base
(Recursion/pythondsConvertinganIntegertoaStringinAnyBase.html)
4.6. Stack Frames: Implementing Recursion
(Recursion/StackFramesImplementingRecursion.html)
4.7. Introduction: Visualizing Recursion (Recursion/pythondsintro-
VisualizingRecursion.html)
4.8. Sierpinski Triangle (Recursion/pythondsSierpinskiTriangle.html)
4.9. Complex Recursive Problems (Recursion/ComplexRecursiveProblems.html)
4.10. Tow er of Hanoi (Recursion/Tow erof Hanoi.html)
4.11. Exploring a Maze (Recursion/ExploringaMaze.html)
4.12. Dynamic Programming (Recursion/DynamicProgramming.html)
4.13. Summary (Recursion/Summary.html)
4.14. Key Terms (Recursion/KeyTerms.html)
4.15. Discussion Questions (Recursion/DiscussionQuestions.html)
4.16. Glossary (Recursion/Glossary.html)
4.17. Programming Exercises (Recursion/pythondsProgrammingExercises.html)
5. Sorting and Searching (SortSearch/toctree.html)

3 of 6
Problem Solving with Algorithms and Data Structures using Python
6/11/17,
... 6:32 PM

5.1. Objectives (SortSearch/Objectives.html)


5.2. Searching (SortSearch/searching.html)
5.3. The Sequential Search (SortSearch/TheSequentialSearch.html)
5.3.1. Analysis of Sequential Search
(SortSearch/TheSequentialSearch.html#analysis-of -sequential-search)
5.4. The Binary Search (SortSearch/TheBinarySearch.html)
5.4.1. Analysis of Binary Search (SortSearch/TheBinarySearch.html#analysis-of -
binary-search)
5.5. Hashing (SortSearch/Hashing.html)
5.5.1. Hash Functions (SortSearch/Hashing.html#hash-f unctions)
5.5.2. Collision Resolution (SortSearch/Hashing.html#collision-resolution)
5.5.3. Implementing the Map Abstract Data Type
(SortSearch/Hashing.html#implementing-the-map-abstract-data-type)
5.5.4. Analysis of Hashing (SortSearch/Hashing.html#analysis-of -hashing)
5.6. Sorting (SortSearch/sorting.html)
5.7. The Bubble Sort (SortSearch/TheBubbleSort.html)
5.8. The Selection Sort (SortSearch/TheSelectionSort.html)
5.9. The Insertion Sort (SortSearch/TheInsertionSort.html)
5.10. The Shell Sort (SortSearch/TheShellSort.html)
5.11. The Merge Sort (SortSearch/TheMergeSort.html)
5.12. The Quick Sort (SortSearch/TheQuickSort.html)
5.13. Summary (SortSearch/Summary.html)
5.14. Key Terms (SortSearch/KeyTerms.html)
5.15. Discussion Questions (SortSearch/DiscussionQuestions.html)
5.16. Programming Exercises (SortSearch/ProgrammingExercises.html)
6. Trees and Tree Algorithms (Trees/toctree.html)
6.1. Objectives (Trees/Objectives.html)
6.2. Examples of Trees (Trees/Examplesof Trees.html)
6.3. Vocabulary and Def initions (Trees/VocabularyandDef initions.html)
6.4. List of Lists Representation (Trees/Listof ListsRepresentation.html)
6.5. Nodes and Ref erences (Trees/NodesandRef erences.html)
6.6. Parse Tree (Trees/ParseTree.html)
6.7. Tree Traversals (Trees/TreeTraversals.html)
6.8. Priority Queues w ith Binary Heaps (Trees/PriorityQueuesw ithBinaryHeaps.html)
6.9. Binary Heap Operations (Trees/BinaryHeapOperations.html)
6.10. Binary Heap Implementation (Trees/BinaryHeapImplementation.html)
6.10.1. The Structure Property (Trees/BinaryHeapImplementation.html#the-structure-
property)
6.10.2. The Heap Order Property (Trees/BinaryHeapImplementation.html#the-heap-
order-property)
6.10.3. Heap Operations (Trees/BinaryHeapImplementation.html#heap-operations)
6.11. Binary Search Trees (Trees/BinarySearchTrees.html)
6.12. Search Tree Operations (Trees/SearchTreeOperations.html)
6.13. Search Tree Implementation (Trees/SearchTreeImplementation.html)
6.14. Search Tree Analysis (Trees/SearchTreeAnalysis.html)
6.15. Balanced Binary Search Trees (Trees/BalancedBinarySearchTrees.html)
6.16. AVL Tree Perf ormance (Trees/AVLTreePerf ormance.html)
6.17. AVL Tree Implementation (Trees/AVLTreeImplementation.html)

4 of 6
Problem Solving with Algorithms and Data Structures using Python
6/11/17,
... 6:32 PM

6.18. Summary of Map ADT Implementations


(Trees/Summaryof MapADTImplementations.html)
6.19. Summary (Trees/Summary.html)
6.20. Key Terms (Trees/KeyTerms.html)
6.21. Discussion Questions (Trees/DiscussionQuestions.html)
6.22. Programming Exercises (Trees/ProgrammingExercises.html)
7. Graphs and Graph Algorithms (Graphs/toctree.html)
7.1. Objectives (Graphs/Objectives.html)
7.2. Vocabulary and Def initions (Graphs/VocabularyandDef initions.html)
7.3. The Graph Abstract Data Type (Graphs/TheGraphAbstractDataType.html)
7.4. An Adjacency Matrix (Graphs/AnAdjacencyMatrix.html)
7.5. An Adjacency List (Graphs/AnAdjacencyList.html)
7.6. Implementation (Graphs/Implementation.html)
7.7. The Word Ladder Problem (Graphs/TheWordLadderProblem.html)
7.8. Building the Word Ladder Graph (Graphs/BuildingtheWordLadderGraph.html)
7.9. Implementing Breadth First Search (Graphs/ImplementingBreadthFirstSearch.html)
7.10. Breadth First Search Analysis (Graphs/BreadthFirstSearchAnalysis.html)
7.11. The Knights Tour Problem (Graphs/TheKnightsTourProblem.html)
7.12. Building the Knights Tour Graph (Graphs/BuildingtheKnightsTourGraph.html)
7.13. Implementing Knights Tour (Graphs/ImplementingKnightsTour.html)
7.14. Knights Tour Analysis (Graphs/KnightsTourAnalysis.html)
7.15. General Depth First Search (Graphs/GeneralDepthFirstSearch.html)
7.16. Depth First Search Analysis (Graphs/DepthFirstSearchAnalysis.html)
7.17. Topological Sorting (Graphs/TopologicalSorting.html)
7.18. Strongly Connected Components (Graphs/StronglyConnectedComponents.html)
7.19. Shortest Path Problems (Graphs/ShortestPathProblems.html)
7.20. Dijkstras Algorithm (Graphs/DijkstrasAlgorithm.html)
7.21. Analysis of Dijkstras Algorithm (Graphs/Analysisof DijkstrasAlgorithm.html)
7.22. Prims Spanning Tree Algorithm (Graphs/PrimsSpanningTreeAlgorithm.html)
7.23. Summary (Graphs/Summary.html)
7.24. Key Terms (Graphs/KeyTerms.html)
7.25. Discussion Questions (Graphs/DiscussionQuestions.html)
7.26. Programming Exercises (Graphs/ProgrammingExercises.html)

Acknowledgements
We are very gratef ul to Franklin Beedle Publishers f or allow ing us to make this interactive textbook
f reely available. This online version is dedicated to the memory of our f irst editor, Jim Leisy, w ho
w anted us to change the w orld.

Indices and tables


Index (genindex.html)
Module Index (py-modindex.html)
Search Page (search.html)

(http://creativecommons.org/licenses/by-nc-sa/4.0/)

5 of 6
Problem Solving with Algorithms and Data Structures using Python
6/11/17,
... 6:32 PM

Problem Solving w ith Algorithms and Data Structures using Python by Bradley
N. Miller, David L. Ranum is licensed under a Creative Commons Attribution-
NonCommercial-ShareAlike 4.0 International License
(http://creativecommons.org/licenses/by-nc-sa/4.0/).

6 of 6

You might also like