# approximation algorithms

Published articles for approximation algorithms.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Hashing to Estimate the Size of a Stream

DevFeed: [Hashing to Estimate the Size of a Stream](<https://devfeed.tech/articles/hashing-to-estimate-the-size-of-a-stream-40394.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2016/01/04/hashing-to-estimate-the-size-of-a-stream/>)

Published: 2016-01-04T09:00:37Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [hashing](<https://devfeed.tech/topics/hashing.md>), [Algorithm](<https://devfeed.tech/topics/algorithm.md>), [data](<https://devfeed.tech/topics/data.md>), [Python](<https://devfeed.tech/topics/python.md>), [parallel](<https://devfeed.tech/topics/parallel.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [approximation-algorithms](<https://devfeed.tech/tags/approximation-algorithms.md>), [data](<https://devfeed.tech/tags/data.md>), [hashing](<https://devfeed.tech/tags/hashing.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [parallel](<https://devfeed.tech/tags/parallel.md>), [programming](<https://devfeed.tech/tags/programming.md>), [python](<https://devfeed.tech/tags/python.md>), [sublinear-algorithms](<https://devfeed.tech/tags/sublinear-algorithms.md>)

### AI overview

This article explains how random hash functions can estimate the number of distinct items in a data stream that is too large to fit in memory. It presents a Python implementation using minimum hash values and parallel hashes to reduce variance, and states approximation guarantees for the estimate.

### Source excerpt

Problem: Estimate the number of distinct items in a data stream that is too large to fit in memory. Solution: (in python) import random def randomHash(modulus): a, b = random.randint(0,modulus-1), random.randint(0,modulus-1) def f(x): return (a*x + b) % modulus return f def average(L): return sum(L) / len(L) def numDistinctElements(stream, numParallelHashes=10): modulus = 2**20 hashes = [randomHash(modulus) for _ in range(numParallelHashes)] minima = [modulus] * numParallelHashes currentEstimate = 0 for i in stream: hashValues = [h(i) for h in hashes] for i, newValue in enumerate(hashValues): if newValue < minima[i]: minima[i] = newValue currentEstimate = modulus / average(minima) yield currentEstimate Discussion: The technique used here is to use random hash functions.

## The Many Faces of Set Cover

DevFeed: [The Many Faces of Set Cover](<https://devfeed.tech/articles/the-many-faces-of-set-cover-40382.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2015/05/04/the-many-faces-of-set-cover/>)

Published: 2015-05-04T09:00:00Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Algorithms, Complexity](<https://devfeed.tech/topics/algorithms-complexity.md>), [Regular expression](<https://devfeed.tech/topics/regular-expression.md>), [Databases](<https://devfeed.tech/topics/databases.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [approximation-algorithms](<https://devfeed.tech/tags/approximation-algorithms.md>), [expression](<https://devfeed.tech/tags/expression.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [np](<https://devfeed.tech/tags/np.md>), [np-hard](<https://devfeed.tech/tags/np-hard.md>), [programming](<https://devfeed.tech/tags/programming.md>), [regex](<https://devfeed.tech/tags/regex.md>), [regex-golf](<https://devfeed.tech/tags/regex-golf.md>), [regular-expressions](<https://devfeed.tech/tags/regular-expressions.md>), [set-cover](<https://devfeed.tech/tags/set-cover.md>)

### AI overview

This tutorial explains the set cover problem and connects it to regex golf. It shows how selected regular expressions can be combined to cover desired strings while avoiding unwanted matches, and notes that set cover is NP-hard, motivating approximation algorithms.

### Source excerpt

A while back Peter Norvig posted a wonderful pair of articles about regex golf. The idea behind regex golf is to come up with the shortest possible regular expression that matches one given list of strings, but not the other. "Regex Golf," by Randall Munroe. In the first article, Norvig runs a basic algorithm to recreate and improve the results from the comic, and in the second he beefs it up with some improved search heuristics.

## When Greedy Algorithms are Good Enough: Submodularity and the (1--1/e)-Approximation

DevFeed: [When Greedy Algorithms are Good Enough: Submodularity and the (1--1/e)-Approximation](<https://devfeed.tech/articles/when-greedy-algorithms-are-good-enough-submodularity-and-the-1-1-e-approximation-40361.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2014/07/07/when-greedy-algorithms-are-good-enough-submodularity-and-the-1-1e-approximation/>)

Published: 2014-07-07T10:00:01Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Algorithms, Complexity](<https://devfeed.tech/topics/algorithms-complexity.md>), [Algorithms](<https://devfeed.tech/topics/algorithms.md>), [Computer science](<https://devfeed.tech/topics/computer-science.md>), [Mathematics](<https://devfeed.tech/topics/mathematics.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [algorithms](<https://devfeed.tech/tags/algorithms.md>), [approximation](<https://devfeed.tech/tags/approximation.md>), [approximation-algorithms](<https://devfeed.tech/tags/approximation-algorithms.md>), [computer-science](<https://devfeed.tech/tags/computer-science.md>), [coverage](<https://devfeed.tech/tags/coverage.md>), [greedy](<https://devfeed.tech/tags/greedy.md>), [greedy-algorithm](<https://devfeed.tech/tags/greedy-algorithm.md>), [matroids](<https://devfeed.tech/tags/matroids.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [submodularity](<https://devfeed.tech/tags/submodularity.md>), [theory](<https://devfeed.tech/tags/theory.md>)

### AI overview

This article explains when greedy algorithms can produce optimal or near-optimal solutions. It introduces submodularity as a diminishing-returns property and discusses how it can provide a reasonably good approximation to the optimal solution.

### Source excerpt

Greedy algorithms are among the simplest and most intuitive algorithms known to humans. Their name essentially gives their description: do the thing that looks best right now, and repeat until nothing looks good anymore or you're forced to stop. Some of the best situations in computer science are also when greedy algorithms are optimal or near-optimal. There is a beautiful theory of this situation, known as the theory of matroids. We haven't covered matroids on this blog (edit: we did), but in this post we will focus on the next best thing: when the greedy algorithm guarantees a reasonably good approximation to the optimal solution.

## Community Detection in Graphs -- a Casual Tour

DevFeed: [Community Detection in Graphs -- a Casual Tour](<https://devfeed.tech/articles/community-detection-in-graphs-a-casual-tour-40357.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2014/05/19/community-detection-in-graphs-a-casual-tour/>)

Published: 2014-05-19T10:00:32Z

Content type: article

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Graphs](<https://devfeed.tech/topics/graphs.md>), [Mathematics](<https://devfeed.tech/topics/mathematics.md>), [Algorithms](<https://devfeed.tech/topics/algorithms.md>), [Algorithms, Complexity](<https://devfeed.tech/topics/algorithms-complexity.md>)

Tags: [approximation](<https://devfeed.tech/tags/approximation.md>), [approximation-algorithms](<https://devfeed.tech/tags/approximation-algorithms.md>), [cliques](<https://devfeed.tech/tags/cliques.md>), [clustering](<https://devfeed.tech/tags/clustering.md>), [community-detection](<https://devfeed.tech/tags/community-detection.md>), [erdos-renyi](<https://devfeed.tech/tags/erdos-renyi.md>), [graph](<https://devfeed.tech/tags/graph.md>), [graphs](<https://devfeed.tech/tags/graphs.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [modularity](<https://devfeed.tech/tags/modularity.md>), [network](<https://devfeed.tech/tags/network.md>), [newman](<https://devfeed.tech/tags/newman.md>), [np-hard](<https://devfeed.tech/tags/np-hard.md>), [power-law-distribution](<https://devfeed.tech/tags/power-law-distribution.md>), [random-graph](<https://devfeed.tech/tags/random-graph.md>), [randomized-algorithm](<https://devfeed.tech/tags/randomized-algorithm.md>), [technical](<https://devfeed.tech/tags/technical.md>), [walktrap](<https://devfeed.tech/tags/walktrap.md>)

### AI overview

This introductory article examines community detection in graphs. It explains the informal idea of a community, why defining one precisely and usefully is difficult, and how the clique-based approach leads to computationally intractable problems, including the NP-hardness of finding the largest clique.

### Source excerpt

Graphs are among the most interesting and useful objects in mathematics. Any situation or idea that can be described by objects with connections is a graph, and one of the most prominent examples of a real-world graph that one can come up with is a social network. Recall, if you aren't already familiar with this blog's gentle introduction to graphs, that a graph $ G$ is defined by a set of vertices $ V$, and a set of edges $ E$, each of which connects two vertices.

## On Coloring Resilient Graphs

DevFeed: [On Coloring Resilient Graphs](<https://devfeed.tech/articles/on-coloring-resilient-graphs-40346.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2014/02/21/on-coloring-resilient-graphs/>)

Published: 2014-02-21T08:45:39Z

Content type: article

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Graphs](<https://devfeed.tech/topics/graphs.md>), [Algorithms](<https://devfeed.tech/topics/algorithms.md>)

Tags: [approximation-algorithms](<https://devfeed.tech/tags/approximation-algorithms.md>), [complexity](<https://devfeed.tech/tags/complexity.md>), [computational-complexity](<https://devfeed.tech/tags/computational-complexity.md>), [graph](<https://devfeed.tech/tags/graph.md>), [graph-coloring](<https://devfeed.tech/tags/graph-coloring.md>), [graphs](<https://devfeed.tech/tags/graphs.md>), [greedy-algorithm](<https://devfeed.tech/tags/greedy-algorithm.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [np-hard](<https://devfeed.tech/tags/np-hard.md>), [research](<https://devfeed.tech/tags/research.md>), [resilience](<https://devfeed.tech/tags/resilience.md>)

### AI overview

An informal explanation of graph coloring, including why deciding 3-colorability is considered NP-hard and several graph properties that can make coloring problems easier. The article also announces the author's paper on resilient graphs.

### Source excerpt

I'm pleased to announce that another paper of mine is finished. This one just got accepted to MFCS 2014, which is being held in Budapest this year (this whole research thing is exciting!). This is joint work with my advisor, Lev Reyzin. As with my first paper, I'd like to explain things here on my blog a bit more informally than a scholarly article allows. A Recent History of Graph Coloring One of the first important things you learn when you study graphs is that coloring graphs is hard.