background preloader

Algorithms

Facebook Twitter

Selection.dvi - selection.pdf. Data Structure Visualization. Sorting Algorithm Animations. Algorithms in Java, Parts 1-4, 3rd edition by Robert Sedgewick. Addison Wesley, 2003. Quicksort is Optimal by Robert Sedgewick and Jon Bentley, Knuthfest, Stanford University, January, 2002. Dual Pivot Quicksort: Code by Discussion. Bubble-sort with Hungarian (“Csángó”) folk dance YouTube video, created at Sapientia University, Tirgu Mures (Marosvásárhely), Romania. Select-sort with Gypsy folk dance YouTube video, created at Sapientia University, Tirgu Mures (Marosvásárhely), Romania. Sorting Out Sorting, Ronald M. Baecker with the assistance of David Sherman, 30 minute color sound film, Dynamic Graphics Project, University of Toronto, 1981. Visual Thinking. Algorithms. Algorithm of the Week: Data Compression with Diagram Encoding and Pattern Substitution.

Two variants of run-length encoding are the diagram encoding and the pattern substitution algorithms. The diagram encoding is actually a very simple algorithm. Unlike run-length encoding, where the input stream must consists of many repeating elements, “aaaaaaaa” for instance, which are very rare in a natural language, there are many so-called “diagrams” in almost any natural language. In plain English there are some diagrams such as “the”, “and”, “ing” (in the word “waiting” for example), “ a”, “ t”, “ e” and many doubled letters. Actually we can extend those diagrams by adding surrounding spaces. Thus we can encode not only “the”, but “ the “, which are 5 characters (2 spaces and 3 letters) with something shorter.

On the other hand, as I said, in plain English there are too many doubled letters, which unfortunately aren’t something special for run-length encoding and the compression ratio will be small. // 8 chars replaced by 8 chars!? // the compressed message is longer!!! CompSci 101 - Big-O notation. I recently had a couple of Google interviews in Tokyo, and while preparing for them I ended up with a huge list of things I wanted to brush up on before the interview. It turns out I didn’t get the job (next time!) , but I thought I might be able to learn something anyway by working through the list and blogging about the main areas that companies like Google expect you to know. I’ve grabbed the domain computerscience101.org (which currently redirects back here), and when I’ve collected enough posts I plan to throw everything up there as a kind of chapter-by-chapter interview-primer in the hope that it might help someone else out. Without further ado, first on the list is Big-O notation: So what is Big-O notation anyway?

Big-O measures how well an operation will “scale” when you increase the amount of “things” it operates on. Big-O can be used to describe how fast an algorithm will run, or it can describe other behaviour such as how much memory an algorithm will use. Common complexity cases. Algorithm Tutorials. Maze Generation: Growing Tree algorithm. # An implementation of the "Growing Tree" algorithm. This one is # notable for it's ability to become nearly identical to Prim's # algorithm, or the Recursive Backtracking algorithm, depending on # how the cells are removed from the list that aggregates as the # algorithm runs. # This script allows you to play with those settings by specifying # the mode after the width and height parameters, as "random" (pull # the cell from list at random), "newest" (pull the newest cell), # "middle" (pull the cell from the middle of the list), "oldest" # (pull the oldest cell), or a combination of any of these, e.g # ruby growing-tree.rb 10 10 newest:50,random:50 # That would select the newest cell half of the time, and a random # cell the other half of the time.

. # commands as well, to be chosen in order, by separating them with # semicolons; each subcommand may then be a comma-delimited list of # options to select randomly: # ruby growing-tree.rb 10 10 "newest;newest;oldest,middle" # see what you get! # 1. . # 2. End. A Real Turing Machine Running The Busy Beaver. A day in the life of… » Deflating the universe. Compression is used all around us every single day. You (or your girlfriend/wife most likely) folds your clothes nicely so they all fit in your closet. When recycling, you flatten the cardboard milkboxes so they take up less space and you probably even text your friends with messages like: “hi, how r u? W r u? Cya, xxx”. Stuff like that. In the computer world, compression probably plays even a more important factor. When compressing data, it take less space and thus less time to send it over to somebody else through internet. Some compression methods can compress and decompress in such a way that the decoded output is exactly the same as the original.

In this article I will talk a bit about the deflate compression method. Deflating GZIP First about gzip. More on the gzip file format can be found on Deflate Deflate is used in many things. Duplicate string eliminationcompression though huffman coding (trees) An example: <title>Test</[6;12] 1.