Algorithmic Thinking 2nd Edition A Problem Based Introduction Daniel Zingaro download
Algorithmic Thinking 2nd Edition A Problem Based Introduction Daniel Zingaro download
https://textbookfull.com/product/algorithmic-thinking-2nd-
edition-a-problem-based-introduction-daniel-zingaro/
https://textbookfull.com/product/algorithmic-thinking-learn-
algorithms-your-coding-skills-2ed-2024-zingaro-d/
https://textbookfull.com/product/problem-based-behavioral-
science-and-psychiatry-2nd-edition-daniel-alicata/
https://textbookfull.com/product/php-and-algorithmic-thinking-
for-the-complete-beginner-2nd-edition-learn-to-think-like-a-
programmer-bouras/
https://textbookfull.com/product/creative-thinking-and-problem-
solving-fabian/
Derivative Pricing a Problem Based Primer First Edition
Lo
https://textbookfull.com/product/derivative-pricing-a-problem-
based-primer-first-edition-lo/
https://textbookfull.com/product/derivative-pricing-a-problem-
based-primer-ambrose-lo/
https://textbookfull.com/product/algorithmic-democracy-a-
critical-perspective-based-on-deliberative-democracy-1st-edition-
garcia-marza/
https://textbookfull.com/product/thinking-fast-and-slow-kahneman-
daniel/
https://textbookfull.com/product/strategic-thinking-in-complex-
problem-solving-1st-edition-arnaud-chevallier/
PRAISE FOR
ALGORITHMIC THINKING, 2ND EDITION
“Algorithmic Thinking will empower you–whether you’re looking to get a
leg up on technical interviews, enter the world of competitive programming,
or just want to sharpen your skills.”
“This book . . . is by far the quickest way to get hands-on experience with
algorithms, and is also a great supplement to more theoretical expositions.”
by Daniel Zingaro
San Francisco
ALGORITHMIC THINKING, 2ND EDITION. Copyright © 2024 by
Daniel Zingaro.
First printing
27 26 25 24 23 12345
No Starch Press and the No Starch Press logo are registered trademarks of
No Starch Press, Inc. Other product and company names mentioned herein
may be the trademarks of their respective owners. Rather than use a
trademark symbol with every occurrence of a trademarked name, we are
using the names only in an editorial fashion and to the benefit of the
trademark owner, with no intention of infringement of the trademark.
Acknowledgments
Introduction
Chapter 9: Union-Find
Afterword
Index
CONTENTS IN DETAIL
FOREWORD
ACKNOWLEDGMENTS
INTRODUCTION
What We’ll Do
Why Use C?
Static Keyword
Include Files
Freeing Memory
Topic Selection
Programming Judges
The Problem
Online Resources
Notes
1
HASH TABLES
The Problem
Hash Tables
The Problem
The Problem
An Ad Hoc Solution
Summary
Notes
The Problem
Binary Trees
The Problem
Sorting Nodes
Summary
Notes
The Problem
Forming a Plan
Solution 1: Recursion
Solution 2: Memoization
Step 3: Memoization
Problem 2: Moneygrubbers
The Problem
Solution 2: Memoization
The Problem
About Rivalries
Solution 1: Recursion
Solution 2: Memoization
A Space Optimization
Summary
Notes
The Problem
The Problem
Summary
Notes
The Problem
Moving Optimally
A Time Optimization
BFS on Graphs
The Problem
Solution 2: A Remodel
The Problem
The BFS
Summary
Notes
The Problem
Dijkstra’s Algorithm
Negative-Weight Edges
The Problem
Adjacency Matrix
Summary
Notes
BINARY SEARCH
The Problem
Testing Feasibility
Searching for a Solution
Binary Search
Determining Feasibility
The Problem
A Greedy Idea
Testing Feasibility
The Problem
Testing Feasibility
The Problem
Solving a Subtask
Using Linear Search
Summary
Notes
The Problem
Max-Heaps
Min-Heaps
Solution 2: Heaps
Heaps
The Problem
Sorting by Label
Solution 1: Recursion
Range Maximum Queries
Segment Trees
Segment Trees
The Problem
Summary
Notes
UNION-FIND
The Problem
Modeling as a Graph
Solution 1: BFS
Union-Find
Solution 2: Union-Find
Optimization 1: Union by Size
Union-Find
Choosing Union-Find
Optimizations
The Problem
Augmenting Union-Find
The Problem
Equivalent Drawers
Summary
Notes
10
RANDOMIZATION
Problem 1: Yōkan
The Problem
Guessing Flavors
Randomization
The Problem
Solving a Subtask
Solution 1: Recursion
Implementing Quicksort
Summary
Notes
AFTERWORD
ALGORITHM RUNTIME
Big O Notation
Linear Time
Constant Time
Another Example
Quadratic Time
PROBLEM CREDITS
INDEX
FOREWORD
For the novice tennis player, keeping the ball in the court is hard enough
(especially from the backhand side). Only after months of practice, once the
basic rallying skills have been mastered, does the sport and its addictive
nature begin to reveal itself. You add to your repertoire more advanced tools
—a slice backhand, a kick serve, a drop volley. You strategize at a higher
level of abstraction—serve and volley, chip and charge, hug the baseline.
You develop intuition for which tools and strategies will be most effective
against different types of opponents—there’s no silver-bullet approach that
works well against everyone.
Programming is like tennis. For the beginning coder, coaxing the computer
to understand what you want it to do—to execute your solution to a problem
—is hard enough. Graduate from this white-belt level and the true problem-
solving fun begins: How do you come up with the solution in the first place?
While there’s no silver-bullet approach that solves every computational
problem efficiently, there are enduringly useful, advanced tools and
strategies: hash tables, search trees, recursion, memoization, dynamic
programming, graph search, and more. And to the trained eye, many
problems and algorithms offer dead giveaways as to which tools are the right
ones. Does your algorithm perform repeated lookups or minimum
computations? Speed it up with a hash table or min-heap, respectively! Can
you build a solution to your problem from solutions to smaller subproblems?
Use recursion! Do the subproblems overlap? Speed up your algorithm with
memoization!
I thank the University of Toronto for offering me the time and space to write.
I thank Naaz Sibia, my technical reviewer, for her careful review of the
manuscript and for finding the time to help me.
I thank Tim Roughgarden for authoring the book’s foreword. Tim’s books
and videos are examples of the kind of clarity that we need to strive for
when teaching algorithms.
I thank everyone who contributed to the problems that I used in this book
and to competitive programming in general. I thank the DMOJ
administrators for their support of my work. Special thanks to Tudor
Brindus, Radu Pogonariu, and Maxwell Cruickshanks for their help in
improving and adding problems.
Finally, I thank all of you for reading this book and wanting to learn.
Random documents with unrelated
content Scribd suggests to you:
them. When Owlglass received the money he made his accomplice a
handsome present and went on his way, leaving the purchasers to
try the virtue of the hat.
This was not the only priest whom Owlglass tricked, as you shall
hear.
HILST staying in the house where the adventure just told you
occurred, he had become acquainted with a priest who came
there several times, and there were two things he did not fail
to note. Firstly, this Priest was very heavy with sleep every day after
dinner, so that it seemed impossible to him to keep his eyes open;
and secondly, he had a handsome silver snuff-box, which it was his
habit to lay down by his side after taking a pinch from it. He lived in
a town at no great distance from Riesenburgh; and thither Owlglass
went to stay a day or two, the very first opportunity he had.
Choosing the time when he knew the Priest had dined, he went to
the confessional, and by means of a rambling story soon sent his
friend asleep, his snuff-box lying by his side as usual. Owlglass then
put the box in his own pocket, and having waked the Priest, said,
“There is one thing weighs very heavily on my mind, for I have
committed the mean crime of theft, and I must beg of you to accept
the stolen article.”
This the Priest refused to do, advising him to restore it to its real
owner; but Owlglass said, “He refuses to accept it.”
“Under those circumstances keep it, my Son, and I give you full
absolution for having committed the great sin of stealing.”
Owlglass then took the box out of his pocket, saying, “This is the
box, and it was from you I stole it; when urged by remorse I wished
to make restoration, but you refused to accept it, giving me full
absolution.”
After this he left the confessional, and shortly after the town.
Owlglass takes the Priest’s Snuff-box.
XIII.
How Owlglass hires himself to a Tailor; and how well he executes his
Master’s Orders.
How Owlglass tells a Truth to a Smith, to his Wife, his Assistant, and
his Maidservant, for which he gets his Horse shod.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com