Muutke küpsiste eelistusi

Common-Sense Guide to Data Structures and Algorithms, 2e [Pehme köide]

  • Formaat: Paperback / softback, 250 pages
  • Ilmumisaeg: 29-Oct-2020
  • Kirjastus: Pragmatic Bookshelf
  • ISBN-10: 1680507222
  • ISBN-13: 9781680507225
Teised raamatud teemal:
  • Formaat: Paperback / softback, 250 pages
  • Ilmumisaeg: 29-Oct-2020
  • Kirjastus: Pragmatic Bookshelf
  • ISBN-10: 1680507222
  • ISBN-13: 9781680507225
Teised raamatud teemal:

If you thought that data structures and algorithms were all just theory, you're missing out on what they can do for your code. Learn to use Big O Notation to make your code run faster by orders of magnitude. Choose from data structures such as hash tables, trees, and graphs to increase your code's efficiency exponentially. With simple language and clear diagrams, this book makes this complex topic accessible, no matter your background. This new edition features practice exercises in every chapter, and new chapters on topics such as dynamic programming and heaps and tries. Get the hands-on info you need to master data structures and algorithms for your day-to-day work.

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. Take a practical approach to data structures and algorithms, with techniques and real-world scenarios that you can use in your daily production code, with examples in JavaScript, Python, and Ruby. This new and revised second edition features new chapters on recursion, dynamic programming, and using Big O in your daily work.

Use Big O notation 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. Practice your new skills with exercises in every chapter, along with detailed solutions.

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

Preface xi
1 Why Data Structures Matter
1(20)
Data Structures
2(1)
The Array: The Foundational Data Structure
3(1)
Measuring Speed
4(1)
Reading
5(3)
Searching
8(3)
Insertion
11(2)
Deletion
13(2)
Sets: How a Single Rule Can Affect Efficiency
15(3)
Wrapping Up
18(1)
Exercises
19(2)
2 Why Algorithms Matter
21(14)
Ordered Arrays
22(2)
Searching an Ordered Array
24(2)
Binary Search
26(5)
Binary Search vs. Linear Search
31(3)
Wrapping Up
34(1)
Exercises
34(1)
3 O Yes! Big O Notation
35(12)
Big O: How Many Steps Relative to N Elements?
36(1)
The Soul of Big O
37(3)
An Algorithm of the Third Kind
40(1)
Logarithms
41(1)
O(log N) Explained
42(1)
Practical Examples
43(2)
Wrapping Up
45(1)
Exercises
45(2)
4 Speeding Up Your Code with Big O
47(16)
Bubble Sort
47(1)
Bubble Sort in Action
48(5)
The Efficiency of Bubble Sort
53(3)
A Quadratic Problem
56(2)
A Linear Solution
58(2)
Wrapping Up
60(1)
Exercises
60(3)
5 Optimizing Code with and Without Big O
63(16)
Selection Sort
63(1)
Selection Sort in Action
64(6)
The Efficiency of Selection Sort
70(1)
Ignoring Constants
71(1)
Big O Categories
72(4)
Wrapping Up
76(1)
Exercises
76(3)
6 Optimizing for Optimistic Scenarios
79(16)
Insertion Sort
79(1)
Insertion Sort in Action
80(6)
The Efficiency of Insertion Sort
86(2)
The Average Case
88(3)
A Practical Example
91(2)
Wrapping Up
93(1)
Exercises
93(2)
7 Big O in Everyday Code
95(18)
Mean Average of Even Numbers
95(2)
Word Builder
97(2)
Array Sample
99(1)
Average Celsius Reading
100(1)
Clothing Labels
101(1)
Count the Ones
102(1)
Palindrome Checker
102(1)
Get All the Products
103(4)
Password Cracker
107(2)
Wrapping Up
109(1)
Exercises
109(4)
8 Blazing Fast Lookup with Hash Tables
113(20)
Hash Tables
113(1)
Hashing with Hash Functions
114(1)
Building a Thesaurus for Fun and Profit, but Mainly Profit
115(2)
Hash Table Lookups
117(2)
Dealing with Collisions
119(3)
Making an Efficient Hash Table
122(2)
Hash Tables for Organization
124(1)
Hash Tables for Speed
125(5)
Wrapping Up
130(1)
Exercises
131(2)
9 Crafting Elegant Code with Stacks and Queues
133(16)
Stacks
133(3)
Abstract Data Types
136(1)
Stacks in Action
137(6)
The Importance of Constrained Data Structures
143(1)
Queues
144(2)
Queues in Action
146(1)
Wrapping Up
147(1)
Exercises
148(1)
10 Recursively Recurse with Recursion
149(12)
Recurse Instead of Loop
149(2)
The Base Case
151(1)
Reading Recursive Code
151(3)
Recursion in the Eyes of the Computer
154(2)
Filesystem Traversal
156(3)
Wrapping Up
159(1)
Exercises
159(2)
11 Learning to Write in Recursive
161(22)
Recursive Category: Repeatedly Execute
161(5)
Recursive Category: Calculations
166(2)
Top-Down Recursion: A New Way of Thinking
168(5)
The Staircase Problem
173(4)
Anagram Generation
177(4)
Wrapping Up
181(1)
Exercises
181(2)
12 Dynamic Programming
183(16)
Unnecessary Recursive Calls
183(4)
The Little Fix for Big O
187(1)
The Efficiency of Recursion
188(1)
Overlapping Subproblems
189(2)
Dynamic Programming through Memoization
191(3)
Dynamic Programming through Going Bottom-Up
194(2)
Wrapping Up
196(1)
Exercises
197(2)
13 Recursive Algorithms for Speed
199(26)
Partitioning
199(6)
Quicksort
205(6)
The Efficiency of Quicksort
211(5)
Quicksort in the Worst-Case Scenario
216(2)
Quickselect
218(4)
Sorting as a Key to Other Algorithms
222(1)
Wrapping Up
223(1)
Exercises
224(1)
14 Node-Based Data Structures
225(22)
Linked Lists
225(2)
Implementing a Linked List
227(2)
Reading
229(2)
Searching
231(1)
Insertion
232(4)
Deletion
236(2)
Efficiency of Linked List Operations
238(1)
Linked Lists in Action
239(1)
Doubly Linked Lists
240(2)
Queues as Doubly Linked Lists
242(2)
Wrapping Up
244(1)
Exercises
244(3)
15 Speeding Up All the Things with Binary Search Trees
247(32)
Trees
248(2)
Binary Search Trees
250(1)
Searching
251(5)
Insertion
256(4)
Deletion
260(11)
Binary Search Trees in Action
271(1)
Binary Search Tree Traversal
272(4)
Wrapping Up
276(1)
Exercises
276(3)
16 Keeping Your Priorities Straight with Heaps
279(26)
Priority Queues
279(2)
Heaps
281(3)
Heap Properties
284(1)
Heap Insertion
285(2)
Looking for the Last Node
287(1)
Heap Deletion
288(4)
Heaps vs. Ordered Arrays
292(1)
The Problem of the Last Node...Again
293(2)
Arrays as Heaps
295(7)
Heaps as Priority Queues
302(1)
Wrapping Up
302(1)
Exercises
303(2)
17 It Doesn't Hurt to Trie
305(26)
Tries
306(1)
Storing Words
307(4)
Trie Search
311(4)
The Efficiency of Trie Search
315(1)
Trie Insertion
316(4)
Building Autocomplete
320(6)
Completing Autocomplete
326(1)
Tries with Values: A Better Autocomplete
327(1)
Wrapping Up
328(1)
Exercises
329(2)
18 Connecting Everything with Graphs
331(56)
Graphs
332(2)
Directed Graphs
334(1)
Object-Oriented Graph Implementation
334(3)
Graph Search
337(2)
Depth-First Search
339(9)
Breadth-First Search
348(13)
The Efficiency of Graph Search
361(3)
Weighted Graphs
364(3)
Dijkstra's Algorithm
367(17)
Wrapping Up
384(1)
Exercises
384(3)
19 Dealing with Space Constraints
387(10)
Big O of Space Complexity
387(3)
Trade-Offs Between Time and Space
390(3)
The Hidden Cost of Recursion
393(2)
Wrapping Up
395(1)
Exercises
395(2)
20 Techniques for Code Optimization
397(42)
Prerequisite: Determine Your Current Big O
397(1)
Start Here: The Best-Imaginable Big O
397(2)
Magical Lookups
399(7)
Recognizing Patterns
406(8)
Greedy Algorithms
414(13)
Change the Data Structure
427(6)
Wrapping Up
433(1)
Parting Thoughts
433(1)
Exercises
434(5)
A1 Exercise Solutions
439(36)
Chapter 1
439(1)
Chapter 2
440(1)
Chapter 3
440(1)
Chapter 4
441(1)
Chapter 5
442(1)
Chapter 6
442(1)
Chapter 7
443(1)
Chapter 8
444(2)
Chapter 9
446(1)
Chapter 10
447(1)
Chapter 11
448(2)
Chapter 12
450(1)
Chapter 13
451(2)
Chapter 14
453(3)
Chapter 15
456(2)
Chapter 16
458(1)
Chapter 17
459(2)
Chapter 18
461(3)
Chapter 19
464(1)
Chapter 20
465(10)
Index 475
Jay Wengrow is an experienced educator and developer who is dedicated to teaching the world to code. He is the founder and CEO of Actualize, a national coding bootcamp and apprenticeship; Anyone Can Learn To Code, an educational company teaching everyone to code through online tutorials, K-12 computer science curriculum, and corporate training.