background preloader

Problems and algorythms

Facebook Twitter

Best paper awards at AAAI, ACL, CHI, CIKM, CVPR, FOCS, FSE, ICCV, ICML, ICSE, IJCAI, KDD, OSDI, PLDI, PODS, SIGIR, SIGMOD, SOSP, STOC, UIST, VLDB, WWW.

Bloom filters

String comparison. Bloom filter. Bloom proposed the technique for applications where the amount of source data would require an impracticably large hash area in memory if "conventional" error-free hashing techniques were applied. He gave the example of a hyphenation algorithm for a dictionary of 500,000 words, out of which 90% follow simple hyphenation rules, but the remaining 10% require expensive disk accesses to retrieve specific hyphenation patterns.

With sufficient core memory, an error-free hash could be used to eliminate all unnecessary disk accesses; on the other hand, with limited core memory, Bloom's technique uses a smaller hash area but still eliminates most unnecessary accesses. For example, a hash area only 15% of the size needed by an ideal error-free hash still eliminates 85% of the disk accesses (Bloom (1970)). More generally, fewer than 10 bits per element are required for a 1% false positive probability, independent of the size or number of elements in the set (Bonomi et al. (2006)). . . . As before. Dijkstra's algorithm. The algorithm exists in many variants; Dijkstra's original variant found the shortest path between two nodes,[3] but a more common variant fixes a single node as the "source" node and finds shortest paths from the source to all other nodes in the graph, producing a shortest-path tree.

For a given source node in the graph, the algorithm finds the shortest path between that node and every other.[4]:196–206 It can also be used for finding the shortest paths from a single node to a single destination node by stopping the algorithm once the shortest path to the destination node has been determined. For example, if the nodes of the graph represent cities and edge path costs represent driving distances between pairs of cities connected by a direct road, Dijkstra's algorithm can be used to find the shortest route between one city and all other cities. Dijkstra's original algorithm does not use a min-priority queue and runs in time (where is the number of nodes). History[edit] Algorithm[edit] is and.

Ray tracing

Donut math: how donut.c works -- a1k0n. There has been a sudden resurgence of interest in my "donut" code from 2006, and I’ve had a couple requests to explain this one. It’s been five years now, so it’s not exactly fresh in my memory, so I will reconstruct it from scratch, in great detail, and hopefully get approximately the same result. This is the code and the output, animated in Javascript: At its core, it’s a framebuffer and a Z-buffer into which I render pixels. Since it’s just rendering relatively low-resolution ASCII art, I massively cheat. All it does is plot pixels along the surface of the torus at fixed-angle increments, and does it densely enough that the final result looks solid. The “pixels” it plots are ASCII characters corresponding to the illumination value of the surface at each point: .,-~:;=!

*#$@ from dimmest to brightest. So how do we do that? \begin{aligned} \frac{y'}{z'} &= \frac{y}{z} \\ y' &= \frac{y z'}{z}. So to project a 3D coordinate to 2D, we scale a coordinate by the screen distance z’. . .

Disruptor pattern

S-99: Ninety-Nine Scala Problems. These are an adaptation of the Ninety-Nine Prolog Problems written by Werner Hett at the Berne University of Applied Sciences in Berne, Switzerland. I (Phil Gold) have altered them to be more amenable to programming in Scala. Feedback is appreciated, particularly on anything marked TODO. The problems have different levels of difficulty. Those marked with a single asterisk (*) are easy. If you have successfully solved the preceeding problems you should be able to solve them within a few (say 15) minutes. Your goal should be to find the most elegant solution of the given problems. Solutions are available by clicking on the link at the beginning of the problem description. [I don't have example solutions to all of the problems yet. Working with lists In Scala, lists are objects of type List[A], where A can be any type.

The solutions to the problems in this section will be in objects named after the problems (P01, P02, etc.). In many cases, there's more than one reasonable approach. Example: Brushing Up on Computer Science Part 4, Algorithms » Victus Spiritus. “An algorithm must be seen to be believed.”Donald Knuth How we ended up here It all began a few days ago with an email from a friend (thanks Denny). I was inspired to dust off my software engineering cap, and review a few choice topics in computer science. What better way to study than to write up a blog post sampling the materials of interest. I accept that in the limited span of blog posts I won’t do proper justice to any topic of sufficient depth, that’s what books are for.

The table of contents for this blog series: Algorithms In short, an algorithm is a recipe. A formula or set of steps for solving a particular problem. Understanding Strategies beats Memorizing Tactics Algorithms are well specified techniques for performing an unbounded variety of tasks (good luck learning all algorithms). There are broad patterns common to vastly separated problem spaces. A couple of the most famous divide and conquer techniques are the FFT and MapReduce (slides, web article). Sorting Algorithms. Neat Algorithms - Flocking. Software Updates: Courgette. The source code does not have this problem because all the entities in the source are symbolic. Functions don't get committed to a specific address until very late in the compilation process, during assembly or linking. If we could step backwards a little and make the internal pointers symbolic again, could we get smaller updates? Courgette uses a primitive disassembler to find the internal pointers.

The disassembler splits the program into three parts: a list of the internal pointer's target addresses, all the other bytes, and an 'instruction' sequence that determines how the plain bytes and the pointers need to be interleaved and adjusted to get back the original input. We call this an 'assembly language' because we can run an 'assembler' to process the instructions and emit a sequence of bytes to recover the original file. We bring the pointers under control by introducing 'labels' for the addresses. How do we use this to generate a better diff? Server: diff = bsdiff(original, update) Challenges - Online backup, file sync, and sharing made easy.