Tricks of the trade: Recursion to Iteration, Part 4: The Trampoline
Related
More from Tom Moertel's Blog
By Tom Moertel Posted on August 23, 2024 Tags: sampling, sql, probability, poisson process, exponential distribution, statistics Sampling is one of the most powerful tools you can wield to extract meaning from large datasets. It lets you reduce a massive pile of data into a small yet representative dataset that’s fast and easy to use. If you...
By Tom Moertel Posted on June 24, 2023 Tags: interview-problems, probability, dice-race In a dice race of degree \(m\) and length \(n\), each player chooses a sequence of \(m\) die rolls. Then we roll a die \(n\) times to generate the race sequence. The player whose sequence occurs first in the race sequence wins. If no player’s sequence occurs...
By Tom Moertel Posted on December 14, 2013 Tags: assembly, 6809, games, hacks A long time ago, when I was a college undergrad, I spent some time working on computer video games. This was in the 8-bit PC era, when the gaming hardware was almost impossibly slow by today’s standards. It might not surprise you, then, to learn that game programmers...
By Tom Moertel Posted on June 3, 2013 Tags: programming, recursion, iteration, python, recursion-to-iteration series, tail calls, data structures This is the third article in a series on converting recursive algorithms into iterative algorithms. If any of what follows seems confusing, you may want to read the earlier articles first. This is an...
By Tom Moertel Posted on May 26, 2013 Tags: programming, python, iterators, streams, SICP, functional programming Recently while solving a programming puzzle in Python, I needed to merge a series of N iterators, each yielding values in sorted order, into a single iterator over the sorted values. The trick is that, when asked for a value from...