Introduction xivI Introduction to Algorithms 11 What is an Algorithm? 3Analyzing Algorithms 4Constant Time 8Logarithmic Time 9Linear Time 10Log-Linear Time 11Quadratic Time 11Cubic Time 13Exponential Time 14Best-Case vs. Worst-Case Complexity 15Space Complexity 15Why is This Important? 16Vocabulary 17Challenge 182 Recursion 19When to Use Recursion 23Vocabulary 23Challenge 233 Search Algorithms 25Linear Search 25When to Use a Linear Search 27Binary Search 27When to Use a Binary Search 30Searching for Characters 32Vocabulary 34Challenge 354 Sorting Algorithms 37Bubble Sort 37When to Use Bubble Sort 41Insertion Sort 42When to Use Insertion Sort 45Merge Sort 45When to Use Merge Sort 52Sorting Algorithms in Python 53Vocabulary 54Challenge 545 String Algorithms 55Anagram Detection 55Palindrome Detection 56Last Digit 57Caesar Cipher 58Vocabulary 61Challenge 616 Math 63Binary 63Bitwise Operators 66FizzBuzz 70Greatest Common Factor 72Euclid's Algorithm 74Primes 75Vocabulary 77Challenge 787 Self-Taught Inspiration: Margaret Hamilton 79II Data Structures 818 What is a Data Structure? 83Vocabulary 85Challenge 869 Arrays 87Array Performance 88Creating an Array 90Moving Zeros 91Combining Two Lists 94Finding the Duplicates in a List 95Finding the Intersection of Two Lists 98Vocabulary 99Challenge 10010 Linked Lists 101Linked List Performance 103Create a Linked List 104Search a Linked List 107Removing a Node from a Linked List 108Reverse a Linked List 109Finding a Linked List Cycle 110Vocabulary 111Challenges 11211 Stacks 113When to Use Stacks 114Creating a Stack 115Using Stacks to Reverse Strings 119Min Stack 120Stacked Parentheses 123Vocabulary 125Challenges 12512 Queues 127When to Use Queues 128Creating a Queue 129Python's Built-In Queue Class 134Create a Queue Using Two Stacks 134Vocabulary 136Challenge 13613 Hash Tables 137When to Use Hash Tables 140Characters in a String 141Two Sum 143Vocabulary 144Challenge 14514 Binary Trees 147When to Use Trees 150Creating a Binary Tree 153Breadth-First Tree Traversal 155More Tree Traversals 157Invert a Binary Tree 160Vocabulary 162Challenges 16215 Binary Heaps 163When to Use Heaps 167Creating a Heap 167Connecting Ropes with Minimal Cost 169Vocabulary 171Challenge 17116 Graphs 173When to Use Graphs 177Creating a Graph 178Dijkstra's Algorithm 180Vocabulary 186Challenge 18717 Self-Taught Inspiration: Elon Musk 18918 Next Steps 191What's Next? 191Climbing the Freelance Ladder 192How to Get an Interview 192How to Prepare for a Technical Interview 193Additional Resources 194Final Thoughts 194Index 195
CORY ALTHOFF is a programmer, speaker, and author whose work includes The Self-Taught Programmer and The Self-Taught Computer Scientist. After graduating with a major in political science, Cory taught himself to program, eventually becoming a software engineer at eBay. Cory's books have been translated into eight languages, and he has been featured in publications like Forbes and CNBC. Over 250K developers are part of the self-taught programmer community he created through his popular Facebook group, course, and newsletter. Cory is a senior vice president at CompTIA, where he helps people learn the skills they need to have successful careers in tech. Cory lives in California with his wife and daughter.