A Common-Sense Guide to Data Structures and Algorithms

Book description

"

Algorithms and data structures are much more than abstract concepts. Mastering them enables you to write code that runs faster and more efficiently, which is particularly important for today’s web and mobile apps. This book takes a practical approach to data structures and algorithms, with techniques and real-world scenarios that you can use in your daily production code. Graphics and examples make these computer science concepts understandable and relevant. You can use these techniques with any language; examples in the book are in JavaScript, Python, and Ruby.

Use Big O notation, the primary tool for evaluating algorithms, to measure and articulate the efficiency of your code, and modify your algorithm to make it faster. Find out how your choice of arrays, linked lists, and hash tables can dramatically affect the code you write. Use recursion to solve tricky problems and create algorithms that run exponentially faster than the alternatives. Dig into advanced data structures such as binary trees and graphs to help scale specialized applications such as social networks and mapping software. You’ll even encounter a single keyword that can give your code a turbo boost. Jay Wengrow brings to this book the key teaching practices he developed as a web development bootcamp founder and educator.

Use these techniques today to make your code faster and more scalable.

"

Publisher resources

View/Submit Errata

Table of contents

  1.  Preface
    1. Who Is This Book For?
    2. What’s in This Book?
    3. How to Read This Book
    4. Online Resources
    5. Acknowledgments
  2. 1. Why Data Structures Matter
    1. The Array: The Foundational Data Structure
    2. Reading
    3. Searching
    4. Insertion
    5. Deletion
    6. Sets: How a Single Rule Can Affect Efficiency
    7. Wrapping Up
  3. 2. Why Algorithms Matter
    1. Ordered Arrays
    2. Searching an Ordered Array
    3. Binary Search
    4. Binary Search vs. Linear Search
    5. Wrapping Up
  4. 3. Oh Yes! Big O Notation
    1. Big O: Count the Steps
    2. Constant Time vs. Linear Time
    3. Same Algorithm, Different Scenarios
    4. An Algorithm of the Third Kind
    5. Logarithms
    6. O(log N) Explained
    7. Practical Examples
    8. Wrapping Up
  5. 4. Speeding Up Your Code with Big O
    1. Bubble Sort
    2. Bubble Sort in Action
    3. Bubble Sort Implemented
    4. The Efficiency of Bubble Sort
    5. A Quadratic Problem
    6. A Linear Solution
    7. Wrapping Up
  6. 5. Optimizing Code with and Without Big O
    1. Selection Sort
    2. Selection Sort in Action
    3. Selection Sort Implemented
    4. The Efficiency of Selection Sort
    5. Ignoring Constants
    6. The Role of Big O
    7. A Practical Example
    8. Wrapping Up
  7. 6. Optimizing for Optimistic Scenarios
    1. Insertion Sort
    2. Insertion Sort in Action
    3. Insertion Sort Implemented
    4. The Efficiency of Insertion Sort
    5. The Average Case
    6. A Practical Example
    7. Wrapping Up
  8. 7. Blazing Fast Lookup with Hash Tables
    1. Enter the Hash Table
    2. Hashing with Hash Functions
    3. Building a Thesaurus for Fun and Profit, but Mainly Profit
    4. Dealing with Collisions
    5. The Great Balancing Act
    6. Practical Examples
    7. Wrapping Up
  9. 8. Crafting Elegant Code with Stacks and Queues
    1. Stacks
    2. Stacks in Action
    3. Queues
    4. Queues in Action
    5. Wrapping Up
  10. 9. Recursively Recurse with Recursion
    1. Recurse Instead of Loop
    2. The Base Case
    3. Reading Recursive Code
    4. Recursion in the Eyes of the Computer
    5. Recursion in Action
    6. Wrapping Up
  11. 10. Recursive Algorithms for Speed
    1. Partitioning
    2. Quicksort
    3. The Efficiency of Quicksort
    4. Worst-Case Scenario
    5. Quickselect
    6. Wrapping Up
  12. 11. Node-Based Data Structures
    1. Linked Lists
    2. Implementing a Linked List
    3. Reading
    4. Searching
    5. Insertion
    6. Deletion
    7. Linked Lists in Action
    8. Doubly Linked Lists
    9. Wrapping Up
  13. 12. Speeding Up All the Things with Binary Trees
    1. Binary Trees
    2. Searching
    3. Insertion
    4. Deletion
    5. Binary Trees in Action
    6. Wrapping Up
  14. 13. Connecting Everything with Graphs
    1. Graphs
    2. Breadth-First Search
    3. Graph Databases
    4. Weighted Graphs
    5. Dijkstra’s Algorithm
    6. Wrapping Up
  15. 14. Dealing with Space Constraints
    1. Big O Notation as Applied to Space Complexity
    2. Trade-Offs Between Time and Space
    3. Parting Thoughts

Product information

  • Title: A Common-Sense Guide to Data Structures and Algorithms
  • Author(s): Jay Wengrow
  • Release date: August 2017
  • Publisher(s): Pragmatic Bookshelf
  • ISBN: 9781680502442