<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.formulasearchengine.com/w/index.php?action=history&amp;feed=atom&amp;title=Parent_function</id>
	<title>Parent function - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://en.formulasearchengine.com/w/index.php?action=history&amp;feed=atom&amp;title=Parent_function"/>
	<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/w/index.php?title=Parent_function&amp;action=history"/>
	<updated>2026-07-22T04:17:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.47.0-wmf.7</generator>
	<entry>
		<id>https://en.formulasearchengine.com/w/index.php?title=Parent_function&amp;diff=29213&amp;oldid=prev</id>
		<title>en&gt;Gilliam: Reverted edits by 63.133.246.253 (talk) to last version by Allthingstoallpeople</title>
		<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/w/index.php?title=Parent_function&amp;diff=29213&amp;oldid=prev"/>
		<updated>2014-01-31T15:46:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;a href=&quot;/w/index.php?title=Help:Reverting&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Help:Reverting (page does not exist)&quot;&gt;Reverted&lt;/a&gt; edits by &lt;a href=&quot;/wiki/Special:Contributions/63.133.246.253&quot; title=&quot;Special:Contributions/63.133.246.253&quot;&gt;63.133.246.253&lt;/a&gt; (&lt;a href=&quot;/w/index.php?title=User_talk:63.133.246.253&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;User talk:63.133.246.253 (page does not exist)&quot;&gt;talk&lt;/a&gt;) to last version by Allthingstoallpeople&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| class=&amp;quot;infobox&amp;quot; style=&amp;quot;width: 20em&amp;quot;&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; style=&amp;quot;font-size: 125%; text-align: center&amp;quot; | Iacono&amp;#039;s working set data structure&lt;br /&gt;
|-&lt;br /&gt;
! Invented&lt;br /&gt;
| 2001&lt;br /&gt;
|-&lt;br /&gt;
! Invented by&lt;br /&gt;
| [[John Iacono]]&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;2&amp;quot; style=&amp;quot;text-align: center; background-color: #CCCCFF; color: #000000;&amp;quot; | Asymptotic complexity&amp;lt;br /&amp;gt;in [[big O notation]]&lt;br /&gt;
|-&lt;br /&gt;
! Space&lt;br /&gt;
| &amp;#039;&amp;#039;O&amp;#039;&amp;#039;(&amp;#039;&amp;#039;n&amp;#039;&amp;#039;)&lt;br /&gt;
|-&lt;br /&gt;
! Search&lt;br /&gt;
| &amp;#039;&amp;#039;O&amp;#039;&amp;#039;(log &amp;#039;&amp;#039;w(x)&amp;#039;&amp;#039;)&lt;br /&gt;
|-&lt;br /&gt;
! Insert&lt;br /&gt;
| &amp;#039;&amp;#039;O&amp;#039;&amp;#039;(log &amp;#039;&amp;#039;n&amp;#039;&amp;#039;)&lt;br /&gt;
|-&lt;br /&gt;
! Delete&lt;br /&gt;
| &amp;#039;&amp;#039;O&amp;#039;&amp;#039;(log &amp;#039;&amp;#039;n&amp;#039;&amp;#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In computer science, Iacono&amp;#039;s working set structure&amp;lt;ref name=WorkingSetStructure /&amp;gt;  is a comparison based [[associative array|dictionary]]. It supports insertion, deletion and access operation to maintain a dynamic set of &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; elements. &lt;br /&gt;
The working set of an item &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; is the set of elements that have been accessed in the structure since the last time that &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; was accessed (or inserted if it was never accessed).&lt;br /&gt;
Inserting and deleting in the working set structure takes &amp;lt;math&amp;gt;O(\log n)&amp;lt;/math&amp;gt; time while accessing an element &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; takes &amp;lt;math&amp;gt;O(\log w(x))&amp;lt;/math&amp;gt;. Here, &amp;lt;math&amp;gt;w(x)&amp;lt;/math&amp;gt; represents the size of  the working set of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Structure==&lt;br /&gt;
&lt;br /&gt;
[[File:Working Set DS.svg|thumbnail|An example of a search for &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; in the working set structure. After finding &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;, it is removed from &amp;lt;math&amp;gt;T_4&amp;lt;/math&amp;gt; and inserted into &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;. Finally, a shift from 1 to 4 is performed in which an element is removed from &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; and inserted into &amp;lt;math&amp;gt;T_{i+1}&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;1\leq i &amp;lt;4&amp;lt;/math&amp;gt;.]]&lt;br /&gt;
To store a dynamic set of &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; elements, this structure consists of a series of &amp;#039;&amp;#039;[[Red–black tree]]&amp;#039;&amp;#039;s, or other &amp;#039;&amp;#039;[[Self-balancing binary search tree]]&amp;#039;&amp;#039;s &amp;lt;math&amp;gt;T_1, T_2, \ldots, T_k&amp;lt;/math&amp;gt;, and a series of &amp;#039;&amp;#039;[[Double-ended queue|deques]]&amp;#039;&amp;#039; (Double-ended queues) &amp;lt;math&amp;gt;Q_1, Q_2, \ldots Q_k&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;k = \lceil \log\log n\rceil&amp;lt;/math&amp;gt;. For every &amp;lt;math&amp;gt;1\leq i\leq k&amp;lt;/math&amp;gt;, tree &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; and deque &amp;lt;math&amp;gt;Q_i&amp;lt;/math&amp;gt; share the same contents and pointers are maintained between their corresponding elements. For every &amp;lt;math&amp;gt; i &amp;lt; k &amp;lt;/math&amp;gt;, the size of &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;Q_i&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;2^{2^i}&amp;lt;/math&amp;gt;. Tree &amp;lt;math&amp;gt;T_k&amp;lt;/math&amp;gt; and deque &amp;lt;math&amp;gt;Q_k&amp;lt;/math&amp;gt; consist of the remaining elements, i.e.,  their size is &amp;lt;math&amp;gt;n - \sum_{i=1}^{k-1} 2^{2^i}&amp;lt;/math&amp;gt;. Therefore, the number of items in all trees and the number of elements in all deques both add up to &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;.&lt;br /&gt;
Every element that has been inserted in the data structure is stored in exactly one of the trees and its corresponding deque.&lt;br /&gt;
&lt;br /&gt;
==Working set Invariant==&lt;br /&gt;
In the deques of this structure, elements are kept in sorted order according to their working set size.&lt;br /&gt;
Formally, element &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; lies after &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; in deque &amp;lt;math&amp;gt;Q_i&amp;lt;/math&amp;gt; if and only if &amp;lt;math&amp;gt;w(x)&amp;lt; w(y)&amp;lt;/math&amp;gt;. Moreover, for every &amp;lt;math&amp;gt;1\leq i &amp;lt; k&amp;lt;/math&amp;gt;, the elements in deque &amp;lt;math&amp;gt;Q_i&amp;lt;/math&amp;gt; have a smaller working sets than the elements in deque &amp;lt;math&amp;gt;Q_{i+1}&amp;lt;/math&amp;gt;. This property is referred to as the Working set invariant. Every operation in the data structure maintains the Working set invariant.&lt;br /&gt;
&lt;br /&gt;
==Operations==&lt;br /&gt;
The basic operation in this structure is called shift from &amp;lt;math&amp;gt;h&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;h&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt; are indices of some trees in the structure. &lt;br /&gt;
Two cases are considered in a shift from &amp;lt;math&amp;gt;h&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt;: If &amp;lt;math&amp;gt;h&amp;lt; j&amp;lt;/math&amp;gt;, then for every &amp;lt;math&amp;gt;h\leq i &amp;lt; j&amp;lt;/math&amp;gt;, taken in increasing order, an item is dequeued from &amp;lt;math&amp;gt;Q_i&amp;lt;/math&amp;gt; and enqueued into &amp;lt;math&amp;gt;Q_{i+1}&amp;lt;/math&amp;gt;. The corresponding item is deleted from &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; and inserted into &amp;lt;math&amp;gt;T_{i+1}&amp;lt;/math&amp;gt;. The running time of this operation is &amp;lt;math&amp;gt;O(\sum_{i=h}^{j} \log |T_i|) = O(\sum_{i=h}^{j} \log 2^{2^i}) = O(2^ j)&amp;lt;/math&amp;gt;. &lt;br /&gt;
Analogously, if &amp;lt;math&amp;gt; j&amp;lt; h&amp;lt;/math&amp;gt;, then for every &amp;lt;math&amp;gt;j &amp;lt; i \leq h&amp;lt;/math&amp;gt;, taken in decreasing order, an item is dequeued from &amp;lt;math&amp;gt;Q_i&amp;lt;/math&amp;gt; and enqueued into &amp;lt;math&amp;gt;Q_{i-1}&amp;lt;/math&amp;gt;. The corresponding item is deleted from &amp;lt;math&amp;gt;T_i&amp;lt;/math&amp;gt; and inserted into &amp;lt;math&amp;gt;T_{i-1}&amp;lt;/math&amp;gt;. The running time of this operation is &amp;lt;math&amp;gt;O(\sum_{i=j}^{h} \log |T_i|) = O(\sum_{i=j}^{h} \log 2^{2^i}) = O(2^ h)&amp;lt;/math&amp;gt;. &lt;br /&gt;
Regardless of the case, after a shift operation, the size of &amp;lt;math&amp;gt;T_h&amp;lt;/math&amp;gt; decreases by one whereas the size of &amp;lt;math&amp;gt;T_j&amp;lt;/math&amp;gt; increases by one.&lt;br /&gt;
Since that elements in the deques are sorted with respect to their working sets sizes, a shift operation maintains the Working set invariant.&lt;br /&gt;
&lt;br /&gt;
===Search===&lt;br /&gt;
To search for an element &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;, search for &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; in &amp;lt;math&amp;gt;T_1, T_2, \ldots T_k&amp;lt;/math&amp;gt;, in increasing order, until finding a tree &amp;lt;math&amp;gt;T_j&amp;lt;/math&amp;gt; containing &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;. If no tree is found, the search is unsuccessful. If &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; is found, it is deleted from &amp;lt;math&amp;gt;T_j&amp;lt;/math&amp;gt; and then inserted into &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt;, i.e., it is moved to the front of the structure. The search finishes by performing a shift from &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt; which restores the size of every tree and every deque to their size prior to the search operation.&lt;br /&gt;
The running time of this search is &amp;lt;math&amp;gt;O(\sum_{i=1}^{j} \log 2^{2^i}) = O(2^ j)&amp;lt;/math&amp;gt; if the search was successful, or &amp;lt;math&amp;gt;O(\sum_{i=j}^{k} \log 2^{2^i}) = O(2^k) = O(\log n)&amp;lt;/math&amp;gt; otherwise.&lt;br /&gt;
By the Working set property, every element in trees &amp;lt;math&amp;gt;T_1, T_2, \ldots, T_{j-1}&amp;lt;/math&amp;gt; belongs to the working set of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;. In particular, every element in &amp;lt;math&amp;gt;T_{j-1}&amp;lt;/math&amp;gt; belongs to the working set of &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and hence, &amp;lt;math&amp;gt;w(x) &amp;gt; |T_{j-1}| = 2^{2^{j-1}}&amp;lt;/math&amp;gt;. Thus, the running time of a successful search is &amp;lt;math&amp;gt;O(2^j) = O(\log 2^{2^{j-1}}) = O(\log w(x))&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Insert===&lt;br /&gt;
Inserting an element &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; into the structure is performed by inserting &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; into &amp;lt;math&amp;gt;T_1&amp;lt;/math&amp;gt; and enqueuing it into &amp;lt;math&amp;gt;Q_1&amp;lt;/math&amp;gt;. Insertion is completed by performing a shift from &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;. &lt;br /&gt;
To avoid overflow, if &amp;lt;math&amp;gt;|T_k| = 2^{2^k}&amp;lt;/math&amp;gt; before the shift, i.e., if the last tree is full, then &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; is incremented and a new empty &amp;lt;math&amp;gt;T_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;Q_k&amp;lt;/math&amp;gt; is created. The running time of this operation is dominated by the shift from &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; whose running time is &amp;lt;math&amp;gt;O(2^k) = O(2^{\log\log n}) = O(\log n)&amp;lt;/math&amp;gt;.&lt;br /&gt;
Since element &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;, whose working set is the smallest, is enqueued in &amp;lt;math&amp;gt;Q_1&amp;lt;/math&amp;gt;, the Working set invariant is preserved after the shift.&lt;br /&gt;
&lt;br /&gt;
===Delete===&lt;br /&gt;
Deleting an element &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; is done by searching for &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; on each tree in the structure, in increasing order, until finding a tree &amp;lt;math&amp;gt;T_j&amp;lt;/math&amp;gt; that contains it (if non is found the deletion is unsuccessful). Item &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; is deleted from &amp;lt;math&amp;gt;T_j&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;Q_j&amp;lt;/math&amp;gt;. Finally, a shift from &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt; maintains the size of &amp;lt;math&amp;gt;T_j&amp;lt;/math&amp;gt; equal to &amp;lt;math&amp;gt;2^{2^j}&amp;lt;/math&amp;gt;. The running time of this operation is &amp;lt;math&amp;gt;O(2^k) = O(\log n)&amp;lt;/math&amp;gt;. The working set invariant is preserved as deleting an element does not change the order of  the working set of the elements.&lt;br /&gt;
&lt;br /&gt;
==Discussion==&lt;br /&gt;
&amp;#039;&amp;#039;[[Splay tree]]&amp;#039;&amp;#039;s are self adjusting search trees introduced by Sleator and Tarjan&amp;lt;ref name=&amp;quot;SleatorTarjan&amp;quot; /&amp;gt; in 1985. Using restructuring heuristic, splay trees are able to achieve insert and delete operations in &amp;lt;math&amp;gt;O(\log n)&amp;lt;/math&amp;gt; [[amortized analysis|amortized]] time, without storing any balance information at the nodes. Moreover, the Working Set Theorem for splay trees states that the cost to access an element in a splay tree is &amp;lt;math&amp;gt;O(\log w(x))&amp;lt;/math&amp;gt; [[amortized analysis|amortized]]. &lt;br /&gt;
Iacono&amp;#039;s workings set structure obtains the same running time for search, insert and delete in the worst-case. Therefore, offering an alternative to splay trees.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist|refs=&lt;br /&gt;
&amp;lt;ref name=WorkingSetStructure&amp;gt;{{cite journal|last=Iacono|first=John|title=Alternatives to splay trees with O(log n) worst-case access times|journal=Proceedings of the twelfth annual ACM-SIAM symposium on Discrete algorithms|year=2001|pages=516–522| url= http://divespot.ca/~morin/teaching/5408/refs/i2001.pdf}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ref name=&amp;quot;SleatorTarjan&amp;quot;&amp;gt;{{Citation |first1=Daniel D. |last1=Sleator |first2=Robert E. |last2=Tarjan |title=Self-Adjusting Binary Search Trees |url=http://www.cs.cmu.edu/~sleator/papers/self-adjusting.pdf |journal=Journal of the ACM ([[Association for Computing Machinery]]) |volume=32 |issue=3 |pages=652–686 |year= 1985 |doi=10.1145/3828.3835 }}&amp;lt;/ref&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Trees (data structures)]]&lt;/div&gt;</summary>
		<author><name>en&gt;Gilliam</name></author>
	</entry>
</feed>