Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithms based on number base systems? [closed]

I've noticed recently that there are a great many algorithms out there based in part or in whole on clever uses of numbers in creative bases. For example:

  • Binomial heaps are based on binary numbers, and the more complex skew binomial heaps are based on skew binary numbers.
  • Some algorithms for generating lexicographically ordered permutations are based on the factoradic number system.
  • Tries can be thought of as trees that look at one digit of the string at a time, for an appropriate base.
  • Huffman encoding trees are designed to have each edge in the tree encode a zero or one in some binary representation.
  • Fibonacci coding is used in Fibonacci search and to invert certain types of logarithms.

My question is: what other algorithms are out there that use a clever number system as a key step of their intuition or proof?. I'm thinking about putting together a talk on the subject, so the more examples I have to draw from, the better.

like image 799
templatetypedef Avatar asked Mar 18 '11 18:03

templatetypedef


People also ask

What is the most efficient base number system?

Base 3, on the other hand, does have a genuine mathematical distinction in its favor. By one plausible measure, it is the most efficient of all integer bases; it offers the most economical way of representing numbers.

Do we use base 10 because we have 10 fingers?

We use base 10 because we have 10 fingers. In base 10, ten digits are used and those digits are 0 through 9. The Mayans used a vigesimal (base 20) number system, the Babylonians used a sexagesimal (base 60) number system, and the Egyptians used a duo-decimal (base 12) number system.

What is the number system we use today?

The most common number system used today is the Decimal Number System in which the base is 10 (because dec means 10). This means that, in our decimal system, we use a total of 10 digits to represent any number in that system.


1 Answers

Chris Okasaki has a very good chapter in his book Purely Functional Data Structures that discusses "Numerical Representations": essentially, take some representation of a number and convert it into a data structure. To give a flavor, here are the sections of that chapter:

  1. Positional Number Systems
  2. Binary Numbers (Binary Random-Access Lists, Zeroless Representations, Lazy Representations, Segmented Representations)
  3. Skew Binary Numbers (Skew Binary Random Access Lists, Skew Binomial Heaps)
  4. Trinary and Quaternary Numbers

Some of the best tricks, distilled:

  • Distinguish between dense and sparse representations of numbers (usually you see this in matrices or graphs, but it's applicable to numbers too!)
  • Redundant number systems (systems that have more than one representation of a number) are useful.
  • If you arrange the first digit to be non-zero or use a zeroless representation, retrieving the head of the data structure can be efficient.
  • Avoid cascading borrows (from taking the tail of the list) and carries (from consing onto the list) by segmenting the data structure

Here is also the reference list for that chapter:

  • Guibas, McCreight, Plass and Roberts: A new representation for linear lists.
  • Myers: An applicative random-access stack
  • Carlsson, Munro, Poblete: An implicit binomial queue with constant insertion time.
  • Kaplan, Tarjan: Purely functional lists with catenation via recursive slow-down.
like image 151
Edward Z. Yang Avatar answered Sep 17 '22 12:09

Edward Z. Yang