Variation of parameters: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
en>Mark viking
Added wl
en>Laudan08
 
Line 1: Line 1:
[[File:Dsu disjoint sets init.svg|thumb|360px|''MakeSet'' creates 8 singletons.]]
[[File:Dsu disjoint sets final.svg|thumb|360px|After some operations of ''Union'', some sets are grouped together.]]
In [[computing]], a '''disjoint-set data structure''' is a [[data structure]] that keeps track of a [[Set (mathematics)|set]] of elements [[partition of a set|partitioned]] into a number of [[disjoint sets|disjoint]] (nonoverlapping) subsets.  A '''union–find algorithm''' is an algorithm that performs two useful operations on such a data structure:
* ''Find'': Determine which subset a particular element is in. This can be used for determining if two elements are in the same subset.
* ''Union'': Join two subsets into a single subset.
Because it supports these two operations, a disjoint-set data structure is sometimes called a ''union–find data structure'' or ''merge–find set''. The other important operation, ''MakeSet'', which makes a set containing only a given element (a [[singleton (mathematics)|singleton]]), is generally trivial. With these three operations, many practical [[partitioning problem]]s can be solved (see the ''Applications'' section).


In order to define these operations more precisely, some way of representing the sets is needed. One common approach is to select a fixed element of each set, called its ''representative'', to represent the set as a whole. Then, ''Find''(x) returns the representative of the set that ''x'' belongs to, and ''Union'' takes two set representatives as its arguments.


== Disjoint-set linked lists ==
[http://Artcross.Com.ua/grafika/four-very-simple-things-you-can-do-save-cool-games artcross.com.ua]Set aside, for the time being, the belief that very few Google Play games support them as yet, and look at the way in which other game networks handle achievements. What makes this different from others here is that this pirates are actually villains along with your job is always to stop them. Enigmo Enigmo is yet another exciting puzzle game for your i - Phone already garnering lots of attention and fans. You SEO friendly help in the developers of the overall game in 2D and 3D games to build up projects for your phone. Games comprise a sizable, and the most  [https://glipads.zendesk.com/entries/43988995-A-Recording-Studio-On-Your-Own-Laptop Mario games Download] visible portion with the i - Tunes App Store. In order to get this done, you need to move the fractions within their right place.<br><br>Many people who have conservative approach regarding business practices feel hesitation about using latest technologies especially related to mobile phone facilities. Unfortunately, this app is integrated with  [http://support.sexy1.com/entries/52070210-Five-Steps-To-Enhance-Employee-Work-Habits temple run cheats] the operating system where there is no strategy to permanently remove Game Center from i - Phone. Checking on customer reviews, Doodle Jump is another best i - Phone app craigs list 1000 perfect five star ratings inside the appstore. While Orkut was pretty preferred among teenagers and university students, Facebook features a broader appeal. The app also provides you with live scores, commentaries, news, video and in-depth coverage.<br><br>In by doing this, you have to recognize that they are certainly not just software installed onto an i - Pod Touch then kept there, as they're tied in to a store account. It should work as your one-stop guide to the World Cup giving you up for the minute scores, photos, videos, standings, city information and of course game schedules.<br><br>Your points are calculated about how far  [https://conit.zendesk.com/entries/76283558-Mhealth-Value-Chain google play sign up] you managed to achieve before colliding. Whether it's pirate games, clothing, books, or perhaps the world famous International Talk Like a Pirate Day, there is certainly no denying that people eyepatch-wearing peglegs may be popular.<br><br>There are seven food types that customers will order however the graphics are unique so there's no strategy to mix them up. To solve this challenge, Zynga could allow a 'learning' setting, where players agree to utilize a dictionary while they play for the purpose of learning new words.<br><br>Fly fishing, bass fishing, saltwater angling and more are all available through the Apple Apps store. As a person you control when a bomb is released then when it detonates with a tap of the finger. On i - Tunes, 99-cents apps are the most sought after products but then you are able to surely experiment using your i - Phone game if you think maybe is engaging and addictive.<br><br>Having multiple monitors is highly recommended for daytrading professionals. Apple has released some great tools that could assist in building an app. Therefore a game based for the famous folklore 'The Thirsty Crow' was though of and shaped into a smoothly functioning gaming application.<br><br>On the other hand, day trading computers are specially designed with all the day trader at heart. The game was launched and received overwhelming response selling those many units in a single day. The large game files of a number of hundred megabytes or a few gigabytes may be downloaded online within few minutes.<br><br>Africa i - Tracker is often a feature-rich i - Phone app providing you with coverage of every one of the games too as each of the important information that you should know in regards to the World Cup. You can have multiple games going plus it does a great job of letting you know what's going on, but I'd love to possess a game with 4 to 5 of my friends all at once. Just dig your personal tunnel for the puddle of water so the alligator may take a shower. You have the purchased or free games from an individual account and then hold the ability to download them again. You can keep track of one's bingo stats as well as save the overall game to the SD card. This could be the best portion of developing an app for your i - Pad tablet.<br><br>Characters appear as miniature office workers roaming the halls. But by using these a large companies  [http://www.mytruthhurts.com/?p=216191 word game Iphone] are available around the platform of all others, including i - Phone, Black - Berry, J2ME and Plam - Pre.<br><br>[http://pinescharter.net/UserProfile/tabid/42/userId/22129/Default.aspx word search iphone] I'm only one one to endure the white face of realization either. Laxtopia is surely an app designed for the global lacrosse community. Research in Motion have not forgotten about the significance of social media on the go.<br><br>Pinball is often a famous game in the physical world, and individuals have been playing it on PCs and laptops since an extended time. Today, Android App Development is making its place just like a competitor in the mobile application technology.<br><br>Some gnomes need liquid water to reduce them, among others need steam. With many Black - Berry models to pick from, the simple truth is to say that developing games for the platform just isn't straightforward. A text book is likely to contain mainly pages and pages of written text with few images.<br><br>
A simple approach to creating a disjoint-set data structure is to create a [[linked list]] for each set. The element at the head of each list is chosen as its representative.


''MakeSet'' creates a list of one element. ''Union'' appends the two lists, a constant-time operation. The drawback of this implementation is that ''Find'' requires [[Big-O notation|Ω]](''n'') or linear time to traverse the list backwards from a given element to the head of the list.
[http://artcross.com.ua/grafika/four-very-simple-things-you-can-do-save-cool-games artcross.com.ua]The app includes detailed instructions and audio guidance from top Nike trainers, with more than 100 custom workouts for you to choose. Upgrades to towers in this game are intricate and in-depth, along with the situations offered within this game will often be very unique. Repeat this until you be able to a page which has no other apps on it.
 
This can be avoided by including in each linked list node a pointer to the head of the list; then ''Find'' takes constant time, since this pointer refers directly to the set representative. However, ''Union'' now has to update each element of the list being appended to make it point to the head of the new combined list, requiring [[Big-O notation|Ω]](''n'') time.
 
When the length of each list is tracked, the required time can be improved by always appending the smaller list to the longer. Using this ''weighted-union heuristic'', a sequence of ''m'' ''MakeSet'', ''Union'', and ''Find'' operations on ''n'' elements requires O(''m''&nbsp;+&nbsp;''n''log&nbsp;''n'') time.<ref name="IntroductionToAlgorithms">{{Citation |first1=Thomas H. |last1=Cormen |author1-link=Thomas H. Cormen |first2=Charles E. |last2=Leiserson |author2-link=Charles E. Leiserson |first3=Ronald L. |last3=Rivest |author3-link=Ronald L. Rivest |first4=Clifford |last4=Stein |author4-link=Clifford Stein |title=[[Introduction to Algorithms]] |edition=Second |publisher=MIT Press |year=2001 |isbn=0-262-03293-7 |chapter=Chapter 21: Data structures for Disjoint Sets |pages=498&ndash;524 }}</ref> For asymptotically faster operations, a different data structure is needed.
 
=== Analysis of the naive approach ===
We now explain the bound <math>O(n \log(n))</math> above.
 
Suppose you have a collection of lists and each node of each list contains an object, the name of the list to which it belongs, and the number of elements in that list. Also assume that the sum of the number of elements in all lists is <math>n</math> (i.e. there are <math>n</math> elements overall). We wish to be able to merge any two of these lists, and update all of their nodes so that they still contain the name of the list to which they belong. The rule for merging the lists <math>A</math> and <math>B</math> is that if <math>A</math> is larger than <math>B</math> then merge the elements of <math>B</math> into <math>A</math> and update the elements that used to belong to <math>B</math>, and vice versa.
 
Choose an arbitrary element of list <math>L</math>, say <math>x</math>. We wish to count how many times in the worst case will <math>x</math> need to have the name of the list to which it belongs updated. The element <math>x</math> will only have its name updated when the list it belongs to is merged with another list of the same size or of greater size. Each time that happens, the size of the list to which <math>x</math> belongs at least doubles. So finally, the question is "how many times can a number double before it is the size of <math>n</math>?" (then the list containing <math>x</math> will contain all <math>n</math> elements). The answer is exactly <math>\log_2(n)</math>. So for any given element of any given list in the structure described, it will need to be updated <math>\log_2(n)</math> times in the worst case. Therefore updating a list of <math>n</math> elements stored in this way takes <math>O(n \log(n))</math> time in the worst case. A find operation can be done in <math>O(1)</math> for this structure because each node contains the name of the list to which it belongs.
 
A similar argument holds for merging the trees in the data structures discussed below. Additionally, it helps explain the time analysis of some operations in the [[binomial heap]] and [[Fibonacci heap]] data structures.
 
== Disjoint-set forests ==
Disjoint-set forests are data structures where each set is represented by a [[tree data structure]], in which each node holds a [[reference]] to its parent node (see [[spaghetti stack]]). They were first described by [[Bernard A. Galler]] and [[Michael J. Fischer]] in 1964,<ref>{{Citation |first=Bernard A. |last=Galler |author1-link=Bernard A. Galler |first2=Michael J. |last2=Fischer |author2-link=Michael J. Fischer |title=An improved equivalence algorithm |journal=[[Communications of the ACM]] |volume=7 |issue=5 |date=May 1964 |pages=301–303 |url=http://portal.acm.org/citation.cfm?doid=364099.364331 |doi=10.1145/364099.364331}}. The paper originating disjoint-set forests.</ref> although their precise analysis took years.
 
In a disjoint-set forest, the representative of each set is the root of that set's tree. ''Find'' follows parent nodes until it reaches the root. ''Union'' combines two trees into one by attaching the root of one to the root of the other. One way of implementing these might be:
 
  '''function''' ''MakeSet''(x)
      x.parent := x
 
  '''function''' ''Find''(x)
      if x.parent == x
        return x
      else
        return ''Find''(x.parent)
 
  '''function''' ''Union''(x, y)
      xRoot := ''Find''(x)
      yRoot := ''Find''(y)
      xRoot.parent := yRoot
 
In this naive form, this approach is no better than the linked-list approach, because the tree it creates can be highly unbalanced; however, it can be enhanced in two ways.
 
The first way, called ''union by rank'', is to always attach the smaller tree to the root of the larger tree. Since it is the depth of the tree that affects the running time, the tree with smaller depth gets added under the root of the deeper tree, which only increases the depth if the depths were equal.  In the context of this algorithm, the term ''rank'' is used instead of ''depth'' since it stops being equal to the depth if path compression (described below) is also used.  One-element trees are defined to have a rank of zero, and whenever two trees of the same rank ''r'' are united, the rank of the result is ''r''+1. Just applying this technique alone yields a worst-case running-time of <math>O(\log n)</math> per ''MakeSet'', ''Union'', or ''Find'' operation. Pseudocode for the improved <code>MakeSet</code> and <code>Union</code>:
 
  '''function''' ''MakeSet''(x)
      x.parent := x
      x.rank  := 0
 
  '''function''' ''Union''(x, y)
      xRoot := ''Find''(x)
      yRoot := ''Find''(y)
      if xRoot == yRoot
          return
      <u>// x and y are not already in same set. Merge them.</u>
      if xRoot.rank < yRoot.rank
          xRoot.parent := yRoot
      else if xRoot.rank > yRoot.rank
          yRoot.parent := xRoot
      else
          yRoot.parent := xRoot
          xRoot.rank := xRoot.rank + 1
 
The second improvement, called ''path compression'', is a way of flattening the structure of the tree whenever ''Find'' is used on it. The idea is that each node visited on the way to a root node may as well be attached directly to the root node; they all share the same representative. To effect this, as <code>Find</code> recursively traverses up the tree, it changes each node's parent reference to point to the root that it found. The resulting tree is much flatter, speeding up future operations not only on these elements but on those referencing them, directly or indirectly. Here is the improved <code>Find</code>:
 
  '''function''' ''Find''(x)
      if x.parent != x
        x.parent := ''Find''(x.parent)
      return x.parent
 
These two techniques complement each other; applied together, the [[amortized analysis|amortized]] time per operation is only <math>O(\alpha(n))</math>, where <math>\alpha(n)</math> is the [[inverse function|inverse of the function]] <math>n = f(x) = A(x,x)</math>, and <math>A</math> is the extremely fast-growing [[Ackermann function]]. Since <math>\alpha(n)</math> is the inverse of this function, <math>\alpha(n)</math> is less than 5 for all remotely practical values of <math>n</math>. Thus, the amortized running time per operation is effectively a small constant.
 
In fact, this is [[asymptotically optimal]]: [[Michael Fredman|Fredman]] and Saks showed in 1989 that <math>\Omega(\alpha(n))</math> words must be accessed by ''any'' disjoint-set data structure per operation on average.<ref>{{Citation |first=M. |last=Fredman |authorlink=Michael Fredman |first2=M. |last2=Saks |title=The cell probe complexity of dynamic data structures |journal=Proceedings of the Twenty-First Annual ACM Symposium on Theory of Computing |pages=345&ndash;354 |date=May 1989 |quote=Theorem 5: Any CPROBE(log ''n'') implementation of the set union problem requires &Omega;(''m'' &alpha;(''m'', ''n'')) time to execute ''m'' Find's and ''n''&minus;1 Union's, beginning with ''n'' singleton sets. }}</ref>
 
== Applications ==
Disjoint-set data structures model the [[Partition of a set|partitioning of a set]], for example to keep track of the [[Connected component (graph theory)|connected components]] of an [[undirected graph]]. This model can then be used to determine whether two vertices belong to the same component, or whether adding an edge between them would result in a cycle.  The Union–Find algorithm is used in high-performance implementations of [[Unification (computer science)|Unification]].<ref>{{cite journal |last1=Knight |first1=Kevin|year=1989 |title=Unification: A multidisciplinary survey |journal=ACM Computing Surveys|pages=93&ndash;124 |url=http://portal.acm.org/citation.cfm?id=62030|doi=10.1145/62029.62030 |volume=21}}</ref>
 
This data structure is used by the [[Boost Graph Library]] to implement its [http://www.boost.org/libs/graph/doc/incremental_components.html Incremental Connected Components] functionality. It is also used  for implementing [[Kruskal's algorithm]] to find the [[minimum spanning tree]] of a graph.
 
Note that the implementation as disjoint-set forests doesn't allow deletion of edges—even without path compression or the rank heuristic.
 
== History ==
While the ideas used in disjoint-set forests have long been familiar, [[Robert Tarjan]] was the first to prove the upper bound (and a restricted version of the lower bound) in terms of the inverse [[Ackermann function]], in 1975.<ref>{{cite journal |last1=Tarjan |first1=Robert Endre |author1-link=Robert E. Tarjan |year=1975 |title=Efficiency of a Good But Not Linear Set Union Algorithm |journal=Journal of the ACM |volume=22 |issue=2 |pages=215&ndash;225 |url=http://portal.acm.org/citation.cfm?id=321884 |doi=10.1145/321879.321884 }}</ref>
Until this time the best bound on the time per operation, proven by [[John Hopcroft|Hopcroft]] and [[Jeffrey Ullman|Ullman]],<ref>{{cite journal |last1=Hopcroft |first1=J. E. |author1-link=John Hopcroft |last2=Ullman |first2=J. D. |author2-link=Jeffrey Ullman |year=1973 |title=Set Merging Algorithms |journal=SIAM Journal on Computing |volume=2 |issue=4 |pages=294&ndash;303 |doi=10.1137/0202024}}</ref>
was [[Proof of O(log*n) time complexity of union–find|O(log<sup>*</sup> n)]], the [[iterated logarithm]] of n, another slowly growing function (but not quite as slow as the inverse Ackermann function).
 
[[Robert E. Tarjan|Tarjan]] and [[Jan van Leeuwen|Van Leeuwen]] also developed one-pass ''Find'' algorithms that are more efficient in practice while retaining the same worst-case complexity.<ref>{{Citation |first=Robert E. |last=Tarjan |author1-link=Robert E. Tarjan |first2=Jan |last2=van Leeuwen |author2-link=Jan van Leeuwen |title=Worst-case analysis of set union algorithms |journal=Journal of the ACM |volume=31 |issue=2 |pages=245–281 |year=1984 |doi= }}</ref>
 
In 2007, Sylvain Conchon and Jean-Christophe Filliâtre developed a [[persistent data structure|persistent]] version of the disjoint-set forest data structure, allowing previous versions of the structure to be efficiently retained, and formalized its correctness using the [[proof assistant]] [[Coq]].<ref>{{Citation |first=Sylvain |last=Conchon |first2=Jean-Christophe |last2=Filliâtre |contribution=A Persistent Union-Find Data Structure |title=ACM SIGPLAN Workshop on ML |location=Freiburg, Germany |date=October 2007}}</ref>
 
==See also==
*[[Partition refinement]], a different data structure for maintaining disjoint sets, with updates that split sets apart rather than merging them together
 
== References ==
{{reflist|30em}}
 
== External links ==
* [http://www.boost.org/libs/disjoint_sets/disjoint_sets.html C++ implementation], part of the [[Boost C++ libraries]]
* [http://www.lix.polytechnique.fr/~nielsen/Srmjava.java A Java implementation with an application to color image segmentation, Statistical Region Merging (SRM), IEEE Trans. Pattern Anal. Mach. Intell. 26(11): 1452–1458 (2004)]
* [http://www.cs.unm.edu/~rlpm/499/uf.html Java applet: A Graphical Union–Find Implementation], by Rory L. P. McGuire
* ''[http://citeseer.ist.psu.edu/anderson94waitfree.html Wait-free Parallel Algorithms for the Union–Find Problem]'', a 1994 paper by Richard J. Anderson and Heather Woll describing a parallelized version of Union–Find that never needs to block
* [http://code.activestate.com/recipes/215912-union-find-data-structure/ Python implementation]
* [http://www.mathblog.dk/disjoint-set-data-structure/ Visual explanation and C# code]
 
[[Category:Data structures]]
[[Category:Search algorithms]]

Latest revision as of 02:05, 28 October 2014


artcross.com.uaSet aside, for the time being, the belief that very few Google Play games support them as yet, and look at the way in which other game networks handle achievements. What makes this different from others here is that this pirates are actually villains along with your job is always to stop them. Enigmo Enigmo is yet another exciting puzzle game for your i - Phone already garnering lots of attention and fans. You SEO friendly help in the developers of the overall game in 2D and 3D games to build up projects for your phone. Games comprise a sizable, and the most Mario games Download visible portion with the i - Tunes App Store. In order to get this done, you need to move the fractions within their right place.

Many people who have conservative approach regarding business practices feel hesitation about using latest technologies especially related to mobile phone facilities. Unfortunately, this app is integrated with temple run cheats the operating system where there is no strategy to permanently remove Game Center from i - Phone. Checking on customer reviews, Doodle Jump is another best i - Phone app craigs list 1000 perfect five star ratings inside the appstore. While Orkut was pretty preferred among teenagers and university students, Facebook features a broader appeal. The app also provides you with live scores, commentaries, news, video and in-depth coverage.

In by doing this, you have to recognize that they are certainly not just software installed onto an i - Pod Touch then kept there, as they're tied in to a store account. It should work as your one-stop guide to the World Cup giving you up for the minute scores, photos, videos, standings, city information and of course game schedules.

Your points are calculated about how far google play sign up you managed to achieve before colliding. Whether it's pirate games, clothing, books, or perhaps the world famous International Talk Like a Pirate Day, there is certainly no denying that people eyepatch-wearing peglegs may be popular.

There are seven food types that customers will order however the graphics are unique so there's no strategy to mix them up. To solve this challenge, Zynga could allow a 'learning' setting, where players agree to utilize a dictionary while they play for the purpose of learning new words.

Fly fishing, bass fishing, saltwater angling and more are all available through the Apple Apps store. As a person you control when a bomb is released then when it detonates with a tap of the finger. On i - Tunes, 99-cents apps are the most sought after products but then you are able to surely experiment using your i - Phone game if you think maybe is engaging and addictive.

Having multiple monitors is highly recommended for daytrading professionals. Apple has released some great tools that could assist in building an app. Therefore a game based for the famous folklore 'The Thirsty Crow' was though of and shaped into a smoothly functioning gaming application.

On the other hand, day trading computers are specially designed with all the day trader at heart. The game was launched and received overwhelming response selling those many units in a single day. The large game files of a number of hundred megabytes or a few gigabytes may be downloaded online within few minutes.

Africa i - Tracker is often a feature-rich i - Phone app providing you with coverage of every one of the games too as each of the important information that you should know in regards to the World Cup. You can have multiple games going plus it does a great job of letting you know what's going on, but I'd love to possess a game with 4 to 5 of my friends all at once. Just dig your personal tunnel for the puddle of water so the alligator may take a shower. You have the purchased or free games from an individual account and then hold the ability to download them again. You can keep track of one's bingo stats as well as save the overall game to the SD card. This could be the best portion of developing an app for your i - Pad tablet.

Characters appear as miniature office workers roaming the halls. But by using these a large companies word game Iphone are available around the platform of all others, including i - Phone, Black - Berry, J2ME and Plam - Pre.

word search iphone I'm only one one to endure the white face of realization either. Laxtopia is surely an app designed for the global lacrosse community. Research in Motion have not forgotten about the significance of social media on the go.

Pinball is often a famous game in the physical world, and individuals have been playing it on PCs and laptops since an extended time. Today, Android App Development is making its place just like a competitor in the mobile application technology.

Some gnomes need liquid water to reduce them, among others need steam. With many Black - Berry models to pick from, the simple truth is to say that developing games for the platform just isn't straightforward. A text book is likely to contain mainly pages and pages of written text with few images.

artcross.com.uaThe app includes detailed instructions and audio guidance from top Nike trainers, with more than 100 custom workouts for you to choose. Upgrades to towers in this game are intricate and in-depth, along with the situations offered within this game will often be very unique. Repeat this until you be able to a page which has no other apps on it.