background preloader

Data Structure Visualization

Data Structure Visualization

Damn Cool Algorithms: Levenshtein Automata Posted by Nick Johnson | Filed under python, coding, tech, damn-cool-algorithms In a previous Damn Cool Algorithms post, I talked about BK-trees, a clever indexing structure that makes it possible to search for fuzzy matches on a text string based on Levenshtein distance - or any other metric that obeys the triangle inequality. Today, I'm going to describe an alternative approach, which makes it possible to do fuzzy text search in a regular index: Levenshtein automata. Introduction The basic insight behind Levenshtein automata is that it's possible to construct a Finite state automaton that recognizes exactly the set of strings within a given Levenshtein distance of a target word. Now let's describe the code to run the simulation and summarize/plot the results. The function simulate does the work; it runs the interaction function to find two actors, then calls the transaction function to figure out how to split their wealth, and repeats this T times. The only other thing it does is record results. Every so-many steps, it records some summary statistics of the population (by default, this will be every 25 steps). What information do we record to summarize the population? Out of the N=5000 (by default) actors, we will record the wealth of exactly nine of them: the ones, in sorted-by-wealth order that occupy the 1% spot (that is, if N=5000, this would be the 50th wealthiest actor), then the 10%, 25% 1/3, and median; and then likewise from the bottom the 1%, 10%, 25% and 1/3.

XOR swap algorithm Using the XOR swap algorithm to exchange nibbles between variables without the use of temporary storage The algorithm[edit] Conventional swapping requires the use of a temporary storage variable. Using the XOR swap algorithm, however, no temporary storage is needed. The algorithm is as follows:[1] The algorithm typically corresponds to three machine code instructions. Damn Cool Algorithms, Part 1: BK-Trees - Nick's Blog - Vimperator Posted by Nick Johnson | Filed under coding, tech, damn-cool-algorithms This is the first post in (hopefully) a series of posts on Damn Cool Algorithms - essentially, any algorithm I think is really Damn Cool, particularly if it's simple but non-obvious. BK-Trees, or Burkhard-Keller Trees are a tree-based data structure engineered for quickly finding near-matches to a string, for example, as used by a spelling checker, or when doing a 'fuzzy' search for a term.

Scrubbing Calculator Bret Victor / May 31, 2011 This page presents an idea for exploring practical algebraic problems without using symbolic variables. I call this tool a "scrubbing calculator", because you solve problems by interactively scrubbing over numbers until you're happy with the results.

Andart: Torus–Earth Torus–Earth One question at Io9 that came up when they published my Double Earth analysis was "What about a toroidal Earth?" This is by no means a new question, and there has been some lengthy discussions online and earlier modelling. Starship Radiators Looking at the Daedalus starship, it might appear at first glance that the ship has no radiators. So why have these cumbersome appendages suddenly reappeared on the Icarus starships? Are they absolutely required? And if so, how do we design them, and how much of a mass penalty will they add to the ship?

Storytelling with Data Feb. 28, 2013 This is a condensed version of my opening keynote at the Tapestry Conference, which was held yesterday in Nashville’s beautiful Union Station Hotel. I’m writing this from memory so at best it will only be an approximation of what I said. Thanks to all the organizers and attendees for a great event. Reinventing Explanation The Babylonian Map of the World is one of the world's oldest extant maps, dating to 600 BCE. It's a crude map, difficult to read at a glance, but fortunately an accompanying cuneiform text describes the features on the map, including Babylon, seven other cities, a canal, and a mountain: Modern maps are, of course, far better than this early map. They improve on it by taking advantage of the many map-making techniques developed since 600 BCE, such as: surveying to get proportions correct; projections to correct for the curvature of the Earth; methods to depict topographic features; and so on. Even ideas such as showing roads and nautical routes were not a priori obvious, but had to be invented. This agglomeration of ideas has turned maps into a powerful medium for thought.