<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.formulasearchengine.com/index.php?action=history&amp;feed=atom&amp;title=Inductive_type</id>
	<title>Inductive type - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://en.formulasearchengine.com/index.php?action=history&amp;feed=atom&amp;title=Inductive_type"/>
	<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/index.php?title=Inductive_type&amp;action=history"/>
	<updated>2026-05-20T18:13:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0-wmf.28</generator>
	<entry>
		<id>https://en.formulasearchengine.com/index.php?title=Inductive_type&amp;diff=24140&amp;oldid=prev</id>
		<title>en&gt;Ninkazu: /* Induction-Recursion */</title>
		<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/index.php?title=Inductive_type&amp;diff=24140&amp;oldid=prev"/>
		<updated>2014-01-19T22:22:54Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Induction-Recursion&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A &amp;#039;&amp;#039;&amp;#039;Fenwick tree&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;binary indexed tree&amp;#039;&amp;#039;&amp;#039; is a data structure providing efficient methods for calculation and manipulation of the [[prefix sum]]s of a table of values. It was proposed by [[Peter Fenwick (computer scientist)|Peter Fenwick]] in 1994.&amp;lt;ref&amp;gt;{{cite journal |author=Peter M. Fenwick |title=A new data structure for cumulative frequency tables |journal=Software: Practice and Experience |volume=24 |issue=3 |year=1994 |pages=327–336 |doi=10.1002/spe.4380240306 |url=http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.14.8917}}&amp;lt;/ref&amp;gt; Fenwick trees primarily solve the problem of balancing prefix sum calculation efficiency with element modification efficiency. The efficiency of these operations comes as a trade-off - greater efficiency in prefix sum calculation is achieved by pre-calculating values, but as more values are pre-calculated more must be re-calculated upon any modification to the underlying value table. Fenwick trees both calculate prefix sums and modify the table in &amp;lt;math&amp;gt;O(\log n)&amp;lt;/math&amp;gt; time, where &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; is the size of the table.&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
Given a table of elements, it is sometimes desirable to calculate the [[running total]] of values up to each index according to some [[Associative property|associative]] [[binary operation]] (addition on integers, for example). Fenwick trees provide a method to query the running total at any index, in addition to allowing changes to the underlying value table and having all further queries reflect those changes. Although Fenwick trees are [[Tree (data structure)|trees]] in concept, in practice they are implemented using a flat array analogous to implementations of a [[binary heap]]. Given an index in the array representing a vertex, the index of a vertex&amp;#039;s parent or child is calculated through [[bitwise operation]]s on the [[Binary numeral system|binary]] representation of its index. Each index contains the pre-calculated sum of a section of the table, and by combining that sum with section sums encountered during an upward traversal to the root, the prefix sum is calculated. When a table value is modified, all section sums which contain the modified value are in turn modified during a similar traversal of the tree. The section sums are defined in such a way that queries and modifications to the table are executed in asymptotically equivalent time - &amp;lt;math&amp;gt;O(\log n)&amp;lt;/math&amp;gt; in the worst case.&lt;br /&gt;
&lt;br /&gt;
The initial process of building the Fenwick tree over a table of values runs in &amp;lt;math&amp;gt;O(n \log n)&amp;lt;/math&amp;gt; time. Other efficient operations include locating the index of a value if all values are positive, or all indices with a given value if all values are non-negative. Also supported is the scaling of all values by a constant factor in &amp;lt;math&amp;gt;O(n)&amp;lt;/math&amp;gt; time. The sum of an arbitrary subarray can also be calculated by subtracting the prefix sum before its start point from the prefix sum at its end point.&lt;br /&gt;
&lt;br /&gt;
==Applications==&lt;br /&gt;
Fenwick trees are used to implement the [[arithmetic coding]] algorithm. Development of operations it supports were primarily motivated by use in that case.&lt;br /&gt;
&lt;br /&gt;
Using a Fenwick tree it is very easy to generate the cumulative sum table. From this cumulative sum table it is possible to calculate the summation of the frequencies in a certain range in order of &amp;lt;math&amp;gt;O(\log n)&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Fenwick tree can also be used to update and query ranges in multidimensional arrays with complexity &amp;lt;math&amp;gt;O(2^d* \log ^d n)&amp;lt;/math&amp;gt;, where d is number of dimensions and n is the number of elements along each dimension. &amp;lt;ref&amp;gt;{{cite journal |author=Pushkar Mishra |title=On Updating and Querying Sub-arrays of Multidimensional Arrays |year=2013 |pages=1-5 |url=http://arxiv.org/abs/1311.6093}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
{{See also|Prefix sums#Applications|l1=Applications of Prefix sums}}&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Prefix sums]]&lt;br /&gt;
* [[Segment tree]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
* [http://www.topcoder.com/tc?module=Static&amp;amp;d1=tutorials&amp;amp;d2=binaryIndexedTrees A tutorial on Fenwick Trees on TopCoder]&lt;br /&gt;
* [http://www.algorithmist.com/index.php/Fenwick_tree An article on Fenwick Trees on Algorithmist]&lt;br /&gt;
* [http://michaelnielsen.org/polymath1/index.php?title=Updating_partial_sums_with_Fenwick_tree An entry on Fenwick Trees on Polymath wiki]&lt;br /&gt;
* [http://pine.cs.yale.edu/pinewiki/OrderStatisticsTree Order-statistics tree, a related data structure]&lt;br /&gt;
&lt;br /&gt;
{{CS-Trees}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Trees (data structures)]]&lt;/div&gt;</summary>
		<author><name>en&gt;Ninkazu</name></author>
	</entry>
</feed>