Pythagorean trigonometric identity: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
en>Solomonfromfinland
en>Arthur Rubin
Undid revision 630809289 by 165.29.145.120 (talk) this no sense makes
 
Line 1: Line 1:
A '''fusion tree''' is a type of [[tree data structure]] that implements an [[associative array]] on ''w''-bit integers. It uses ''O''(''n'') space and performs searches in ''O''(log<sub>''w''</sub> ''n'') time, which is asymptotically faster than a traditional [[self-balancing binary search tree]], and actually better than the [[van Emde Boas tree]] when ''w'' is large. It achieves this speed by exploiting certain constant-time operations that can be done on a [[machine word]]. Fusion trees were invented in 1990 by [[Michael Fredman]] and [[Dan Willard]].<ref>M. L. Fredman and D. E. Willard. BLASTING through the information theoretic barrier with FUSION TREES. Proceedings of the twenty-second annual ACM symposium on Theory of Computing, 1-7, 1990.</ref>


Several advances have been made since Fredman and Willard's original 1990 paper. In 1999 <ref>A. Andersson, P. B. Miltersen, and M. Thorup. Fusion trees can be implemented with AC0 instructions only. Theoretical Computer Science, 215:337-344, 1999.</ref> it was shown how to implement fusion trees under the AC<sup>0</sup> model, in which multiplication no longer takes constant time. A dynamic version of fusion trees using [[Hash tables]] was proposed in 1996 <ref>R. Raman. Priority queues: Small, monotone, and trans-dichotomous. Algorithms - ESA ’96, 121-137, 1996.</ref> which matched the ''O''(log<sub>''w''</sub> ''n'') runtime in expectation. Another dynamic version using [[Exponential tree]] was proposed in 2007 <ref>A. Andersson and M. Thorup. Dynamic ordered sets with exponential search trees. Journal of the ACM, 54:3:13, 2007.</ref> which yields worst-case runtimes of ''O''(log<sub>''w''</sub> ''n'' + log log ''u'') per operation, where ''u'' is the size of the largest key. It remains open whether dynamic fusion trees can achieve ''O''(log<sub>''w''</sub> ''n'') per operation with high probability.


== How it works ==
Consuelo Gelinas is what her [http://Search.Un.org/search?ie=utf8&site=un_org&output=xml_no_dtd&client=UN_Website_en&num=10&lr=lang_en&proxystylesheet=UN_Website_en&oe=utf8&q=husband&Submit=Go husband] loves to call her but it's not the most female name out there. [http://photobucket.com/images/North+Dakota North Dakota] is the only place I've been residing in but I will have to move in a year or two. She utilized to be unemployed but now he is a production and distribution officer. Home brewing is the pastime I will never stop performing. Check out the latest information on her website: http://dev.interactivedlp.com/content/three-stunning-examples-beautiful-nya-online-svenska-casino-p%C3%A5-n%C3%A4tet<br><br>Have a look at my weblog: [http://dev.interactivedlp.com/content/three-stunning-examples-beautiful-nya-online-svenska-casino-p%C3%A5-n%C3%A4tet nya online svenska casino]
A fusion tree is essentially a [[B-tree]] with branching factor of ''w''<sup>1/5</sup> (any small exponent is also possible), which gives it a height of ''O''(log<sub>''w''</sub> ''n''). To achieve the desired runtimes for updates and queries, the fusion tree must be able to search a node containing up to ''w''<sup>1/5</sup> keys in constant time. This is done by compressing ("sketching") the keys so that all can fit into one machine word, which in turn allows comparisons to be done in parallel. The rest of this article will describe the operation of a static Fusion Tree; that is, only queries are supported.
 
== Sketching ==
Sketching is the method by which each ''w''-bit key at a node containing ''k'' keys is compressed into only ''k''-1 bits. Each key ''x'' may be thought of as a path in the full binary tree of height ''w'' starting at the root and ending at the leaf corresponding to ''x''. To distinguish two paths, it suffices to look at their branching point (the first bit where the two keys differ). All ''k'' paths together have ''k''-1 branching points, so at most ''k''-1 bits are needed to distinguish any two of the ''k'' keys.
 
[[File:FusionTreeSketch.gif|center|Visualization of the sketch function.]]
 
An important property of the sketch function is that it preserves the order of the keys. That is, <code>sketch</code>(''x'') &lt; <code>sketch</code>(''y'') for any two keys ''x'' &lt; ''y''.
 
== Approximating the sketch ==
If the locations of the sketch bits are ''b''<sub>1</sub> &lt; ''b''<sub>2</sub> &lt; &middot;&middot;&middot; &lt; ''b''<sub>''r''</sub>, then the sketch of the key ''x''<sub>''w''-1</sub>&middot;&middot;&middot;''x''<sub>1</sub>''x''<sub>0</sub> is the ''r''-bit integer <math>x_{b_r}x_{b_{r-1}}\cdots x_{b_1}</math>.
 
With only standard word operations, such as those of the [[C programming language]], it is difficult to directly compute the sketch of a key in constant time. Instead, the sketch bits can be packed into a range of size at most ''r''<sup>4</sup>, using [[bitwise AND]] and multiplication. The bitwise AND operation serves to clear all non-sketch bits from the key, while the multiplication shifts the sketch bits into a small range. Like the "perfect" sketch, the approximate sketch preserves the order of the keys.
 
Some preprocessing is needed to determine the correct multiplication constant. Each sketch bit in location ''b''<sub>''i''</sub> will get shifted to ''b''<sub>''i''</sub> + ''m''<sub>''i''</sub> via a multiplication by ''m'' = <math>\textstyle\sum_{i=1}^r</math> 2<sup>''m''<sub>''i''</sub></sup>. For the approximate sketch to work, the following three properties must hold:
# ''b''<sub>''i''</sub> + ''m''<sub>''j''</sub> are distinct for all pairs (''i'', ''j''). This will ensure that the sketch bits are uncorrupted by the multiplication.
# ''b''<sub>''i''</sub> + ''m''<sub>''j''</sub> is a strictly increasing function of ''i''. That is, the order of the sketch bits is preserved.
# (''b''<sub>''r''</sub> + ''m''<sub>''r''</sub>) - (''b''<sub>1</sub> - ''m''<sub>1</sub>) ≤ ''r''<sup>4</sup>. That is, the sketch bits are packed into a range of size at most ''r''<sup>4</sup>.
 
An inductive argument shows how the ''m''<sub>''i''</sub> can be constructed. Let ''m''<sub>1</sub> = ''w'' &minus; ''b''<sub>1</sub>. Suppose that 1 &lt; ''t'' ≤ ''r'' and that ''m''<sub>1</sub>, ''m''<sub>2</sub>... ''m''<sub>''t-1''</sub> have already been chosen. Then pick the smallest integer ''m''<sub>''t''</sub> such that both properties (1) and (2) are satisfied. Property (1) requires that ''m''<sub>''t''</sub> ≠ ''b''<sub>''i''</sub> &minus; ''b''<sub>''j''</sub> + ''m''<sub>''l''</sub> for all 1 ≤ ''i'', ''j'' ≤ ''r'' and 1 ≤ ''l'' ≤ ''t''-1. Thus, there are less than ''tr''<sup>2</sup> ≤ ''r''<sup>3</sup> values that ''m''<sub>''t''</sub> must avoid. Since ''m''<sub>''t''</sub> is chosen to be minimal, (''b''<sub>''t''</sub> + ''m''<sub>''t''</sub>) ≤ (''b''<sub>''t''-1</sub> + ''m''<sub>''t''-1</sub>) + ''r''<sup>3</sup>. This implies Property (3).
 
The approximate sketch is thus computed as follows:
# Mask out all but the sketch bits with a bitwise AND.
# Multiply the key by the predetermined constant ''m''. This operation actually requires two machine words, but this can still by done in constant time.
# Mask out all but the shifted sketch bits. These are now contained in a contiguous block of at most ''r''<sup>4</sup> &lt; ''w''<sup>4/5</sup> bits.
 
For the rest of this article, sketching will be taken to mean approximate sketching.
 
== Parallel comparison ==
The purpose of the compression achieved by sketching is to allow all of the keys to be stored in one ''w''-bit word. Let the ''node sketch'' of a node be the bit string
 
:1<code>sketch</code>(''x''<sub>1</sub>)1<code>sketch</code>(''x''<sub>2</sub>)...1<code>sketch</code>(''x''<sub>''k''</sub>)
 
We can assume that the sketch function uses exactly ''b'' ≤ ''r''<sup>4</sup> bits. Then each block uses 1 + ''b'' ≤ ''w''<sup>4/5</sup> bits, and since ''k'' ≤ ''w''<sup>1/5</sup>, the total number of bits in the node sketch is at most ''w''.
 
A brief notational aside: for a bit string ''s'' and nonnegative integer ''m'', let ''s''<sup>''m''</sup> denote the concatenation of ''s'' to itself ''m'' times. If ''t'' is also a bit string ''st'' denotes the concatenation of ''t'' to ''s''.
 
The node sketch makes it possible to search the keys for any ''b''-bit integer ''y''. Let ''z'' = (0''y'')<sup>''k''</sup>, which can be computed in constant time (multiply ''y'' by the constant (0<sup>''b''</sup>1)<sup>''k''</sup>). Note that 1<code>sketch</code>(''x''<sub>''i''</sub>) - 0''y'' is always positive, but preserves its leading 1 iff <code>sketch</code>(''x''<sub>''i''</sub>) ≥ ''y''. We can thus compute the smallest index ''i'' such that <code>sketch</code>(''x''<sub>''i''</sub>) ≥ ''y'' as follows:
 
# Subtract ''z'' from the node sketch.
# Take the bitwise AND of the difference and the constant (10<sup>''b''</sup>)<sup>''k''</sup>. This clears all but the leading bit of each block.
# Find the [[most significant bit]] of the result.
# Compute ''i'', using the fact that the leading bit of the ''i''-th block has index ''i''(''b''+1).
 
== Desketching ==
For an arbitrary query ''q'', parallel comparison computes the index ''i'' such that
:<code>sketch</code>(''x''<sub>''i''-1</sub>) ≤ <code>sketch</code>(''q'') ≤ <code>sketch</code>(''x''<sub>''i''</sub>)
Unfortunately, the sketch function is not in general order-preserving outside the set of keys, so it is not necessarily the case that ''x''<sub>''i''-1</sub> ≤ ''q'' ≤ ''x''<sub>''i''</sub>. What is true is that, among all of the keys, either ''x''<sub>''i''-1</sub> or ''x''<sub>''i''</sub> has the longest common prefix with ''q''. This is because any key ''y'' with a longer common prefix with ''q'' would also have more sketch bits in common with ''q'', and thus <code>sketch</code>(''y'') would be closer to <code>sketch</code>(''q'') than any <code>sketch</code>(''x''<sub>''j''</sub>).
 
The length longest common prefix between two ''w''-bit integers ''a'' and ''b'' can be computed in constant time by finding the most significant bit of the [[bitwise XOR]] between ''a'' and ''b''. This can then be used to mask out all but the longest common prefix.
 
Note that ''p'' identifies exactly where ''q'' branches off from the set of keys. If the next bit of ''q'' is 0, then the successor of ''q'' is contained in the ''p''1 subtree, and if the next bit of ''q'' is 1, then the predecessor of ''q'' is contained in the ''p''0 subtree. This suggests the following algorithm:
 
# Use parallel comparison to find the index ''i'' such that <code>sketch</code>(''x''<sub>''i''-1</sub>) ≤ <code>sketch</code>(''q'') ≤ <code>sketch</code>(''x''<sub>''i''</sub>).
# Compute the longest common prefix ''p'' of ''q'' and either ''x''<sub>''i''-1</sub> or ''x''<sub>''i''</sub> (taking the longer of the two).
# Let ''l''-1 be the length of the longest common prefix ''p''.
## If the ''l''-th bit of ''q'' is 0, let ''e'' = ''p''10<sup>''w''-''l''</sup>. Use parallel comparison to search for the successor of <code>sketch</code>(''e''). This is the actual predecessor of ''q''.
## If the ''l''-th bit of ''q'' is 1, let ''e'' = ''p''01<sup>''w''-''l''</sup>. Use parallel comparison to search for the predecessor of <code>sketch</code>(''e''). This is the actual successor of ''q''.
# Once either the predecessor or successor of ''q'' is found, the exact position of ''q'' among the set of keys is determined.
 
== References ==
{{reflist}}
* [http://theory.csail.mit.edu/classes/6.897/spring03/scribe_notes/L4/lecture4.pdf MIT CS 6.897: Advanced Data Structures: Lecture 4, Fusion Trees], Prof. Erik Demaine (Spring 2003)
* [http://theory.csail.mit.edu/classes/6.897/spring03/scribe_notes/L5/lecture5.pdf MIT CS 6.897: Advanced Data Structures: Lecture 5, More fusion trees; self-organizing data structures, move-to-front, static optimality], Prof. Erik Demaine (Spring 2003)
* [http://courses.csail.mit.edu/6.851/spring07/scribe/lec13.pdf MIT CS 6.851: Advanced Data Structures: Lecture 13, Fusion Tree notes], Prof. Erik Demaine (Spring 2007)
* [http://courses.csail.mit.edu/6.851/spring12/scribe/lec12.pdf MIT CS 6.851: Advanced Data Structures: Lecture 12, Fusion Tree notes], Prof. Erik Demaine (Spring 2012)
 
{{CS-Trees}}
 
[[Category:Trees (data structures)]]
[[Category:Associative arrays]]

Latest revision as of 11:21, 19 November 2014


Consuelo Gelinas is what her husband loves to call her but it's not the most female name out there. North Dakota is the only place I've been residing in but I will have to move in a year or two. She utilized to be unemployed but now he is a production and distribution officer. Home brewing is the pastime I will never stop performing. Check out the latest information on her website: http://dev.interactivedlp.com/content/three-stunning-examples-beautiful-nya-online-svenska-casino-p%C3%A5-n%C3%A4tet

Have a look at my weblog: nya online svenska casino