This page allows you to examine the variables generated by the Edit Filter for an individual change.

Variables generated for this change

VariableValue
Whether or not the edit is marked as minor (no longer in use) (minor_edit)
false
Edit count of the user (user_editcount)
null
Name of the user account (user_name)
'45.59.229.42'
Age of the user account (user_age)
0
Groups (including implicit) the user is in (user_groups)
[ 0 => '*' ]
Rights that the user has (user_rights)
[ 0 => 'createaccount', 1 => 'read', 2 => 'edit', 3 => 'createtalk', 4 => 'writeapi', 5 => 'editmyusercss', 6 => 'editmyuserjs', 7 => 'viewmywatchlist', 8 => 'editmywatchlist', 9 => 'viewmyprivateinfo', 10 => 'editmyprivateinfo', 11 => 'editmyoptions', 12 => 'abusefilter-view', 13 => 'abusefilter-log', 14 => 'abusefilter-log-detail', 15 => 'centralauth-merge', 16 => 'vipsscaler-test', 17 => 'ep-bereviewer' ]
Global groups that the user is in (global_user_groups)
[]
Whether or not a user is editing through the mobile interface (user_mobile)
false
Page ID (page_id)
41437742
Page namespace (page_namespace)
0
Page title without namespace (page_title)
'Heap's algorithm'
Full page title (page_prefixedtitle)
'Heap's algorithm'
Last ten users to contribute to the page (page_recent_contributors)
[ 0 => 'Glrx', 1 => '27.5.213.106', 2 => '216.171.51.22', 3 => 'MattiasFredsberg', 4 => '109.63.174.16', 5 => 'WhackTheWiki', 6 => 'Trlkly', 7 => '2604:2000:800A:AAF0:E1C9:4133:2577:A180', 8 => 'Mujina93', 9 => '94.114.24.22' ]
Action (action)
'edit'
Edit summary/reason (summary)
'/* Details of the algorithm */ '
Old content model (old_content_model)
'wikitext'
New content model (new_content_model)
'wikitext'
Old page wikitext, before the edit (old_wikitext)
'[[File:Heap algorithm with 4 elements.svg|thumb|90px|A map of the 24 permutations and the 23 swaps used in Heap's algorithm permuting the four letters A (amber), B (blue), C (cyan) and D (dark red)]] '''Heap's [[algorithm]]''' generates all possible [[permutation]]s of {{math|''n''}} objects. It was first proposed by B. R. Heap in 1963.<ref name="Heap">{{cite journal|last=Heap|first=B. R.|title=Permutations by Interchanges|journal=The Computer Journal|year=1963|volume=6|issue=3|pages=293–4|url=http://comjnl.oxfordjournals.org/content/6/3/293.full.pdf|doi=10.1093/comjnl/6.3.293}}</ref> The algorithm minimizes movement: it generates each permutation from the previous one by interchanging a single pair of elements; the other {{math|''n''−2}} elements are not disturbed. In a 1977 review of permutation-generating algorithms, [[Robert Sedgewick (computer scientist)|Robert Sedgewick]] concluded that it was at that time the most effective algorithm for generating permutations by computer.<ref>{{Cite journal | last1 = Sedgewick | first1 = R. | title = Permutation Generation Methods | doi = 10.1145/356689.356692 | journal = ACM Computing Surveys | volume = 9 | issue = 2 | pages = 137–164| year = 1977 | pmid = | pmc = }}</ref> The sequence of permutations of {{math|''n''}} objects generated by Heap's algorithm is the beginning of the sequence of permutations of {{math|''n''+1}} objects. So there is one infinite sequence of permutations generated by Heap's algorithm {{OEIS|A280318}}. == Details of the algorithm == Suppose we have a permutation containing {{math|''n''}} different elements. Heap found a systematic method for choosing at each step a pair of elements to switch, in order to produce every possible permutation of these elements exactly once. Let us describe Heap's method in a recursive way. First we set a counter {{math|''i''}} to 0. Now we perform the following steps repeatedly until {{math|''i''}} is equal to {{math|''n''}}. We use the algorithm to generate the {{math|(''n''−1)!}} permutations of the first {{math|''n''−1}} elements, adjoining the last element to each of these. This generates all of the permutations that end with the last element. Then if {{math|''n''}} is odd, we switch the first element and the last one, while if {{math|''n''}} is even we can switch the {{math|''i''}}th element and the last one (there is no difference between {{math|''n''}} even and odd in the first iteration). We add one to the counter {{math|''i''}} and repeat. In each iteration, the algorithm will produce all of the permutations that end with the element that has just been moved to the "last" position. The following pseudocode outputs all permutations of a data array of length {{math|''n''}}. <source lang="pascal"> procedure generate(n : integer, A : array of any): if n = 1 then output(A) else for i := 0; i < n - 1; i += 1 do generate(n - 1, A) if n is even then swap(A[i], A[n-1]) else swap(A[0], A[n-1]) end if end for generate(n - 1, A) end if </source> One can also write the algorithm in a non-recursive format.<ref>{{cite web|last=Sedgewick|first=Robert|title=a talk on Permutation Generation Algorithms|url=http://www.cs.princeton.edu/~rs/talks/perms.pdf}}</ref> <source lang="pascal"> procedure generate(n : integer, A : array of any): c : array of int for i := 0; i < n; i += 1 do c[i] := 0 end for output(A) i := 0; while i < n do if c[i] < i then if i is even then swap(A[0], A[i]) else swap(A[c[i]], A[i]) end if output(A) c[i] += 1 i := 0 else c[i] := 0 i += 1 end if end while </source> ==See also== * [[Steinhaus–Johnson–Trotter algorithm]] ==References== {{Reflist}} [[Category:Combinatorial algorithms]] [[Category:Permutations]]'
New page wikitext, after the edit (new_wikitext)
'[[File:Heap algorithm with 4 elements.svg|thumb|90px|A map of the 24 permutations and the 23 swaps used in Heap's algorithm permuting the four letters A (amber), B (blue), C (cyan) and D (dark red)]] '''Heap's [[algorithm]]''' generates all possible [[permutation]]s of {{math|''n''}} objects. It was first proposed by B. R. Heap in 1963.<ref name="Heap">{{cite journal|last=Heap|first=B. R.|title=Permutations by Interchanges|journal=The Computer Journal|year=1963|volume=6|issue=3|pages=293–4|url=http://comjnl.oxfordjournals.org/content/6/3/293.full.pdf|doi=10.1093/comjnl/6.3.293}}</ref> The algorithm minimizes movement: it generates each permutation from the previous one by interchanging a single pair of elements; the other {{math|''n''−2}} elements are not disturbed. In a 1977 review of permutation-generating algorithms, [[Robert Sedgewick (computer scientist)|Robert Sedgewick]] concluded that it was at that time the most effective algorithm for generating permutations by computer.<ref>{{Cite journal | last1 = Sedgewick | first1 = R. | title = Permutation Generation Methods | doi = 10.1145/356689.356692 | journal = ACM Computing Surveys | volume = 9 | issue = 2 | pages = 137–164| year = 1977 | pmid = | pmc = }}</ref> The sequence of permutations of {{math|''n''}} objects generated by Heap's algorithm is the beginning of the sequence of permutations of {{math|''n''+1}} objects. So there is one infinite sequence of permutations generated by Heap's algorithm {{OEIS|A280318}}. ==See also== * [[Steinhaus–Johnson–Trotter algorithm]] ==References== {{Reflist}} [[Category:Combinatorial algorithms]] [[Category:Permutations]]'
Unified diff of changes made by edit (edit_diff)
'@@ -4,54 +4,4 @@ The sequence of permutations of {{math|''n''}} objects generated by Heap's algorithm is the beginning of the sequence of permutations of {{math|''n''+1}} objects. So there is one infinite sequence of permutations generated by Heap's algorithm {{OEIS|A280318}}. - -== Details of the algorithm == -Suppose we have a permutation containing {{math|''n''}} different elements. Heap found a systematic method for choosing at each step a pair of elements to switch, in order to produce every possible permutation of these elements exactly once. Let us describe Heap's method in a recursive way. First we set a counter {{math|''i''}} to 0. Now we perform the following steps repeatedly until {{math|''i''}} is equal to {{math|''n''}}. We use the algorithm to generate the {{math|(''n''−1)!}} permutations of the first {{math|''n''−1}} elements, adjoining the last element to each of these. This generates all of the permutations that end with the last element. Then if {{math|''n''}} is odd, we switch the first element and the last one, while if {{math|''n''}} is even we can switch the {{math|''i''}}th element and the last one (there is no difference between {{math|''n''}} even and odd in the first iteration). We add one to the counter {{math|''i''}} and repeat. In each iteration, the algorithm will produce all of the permutations that end with the element that has just been moved to the "last" position. The following pseudocode outputs all permutations of a data array of length {{math|''n''}}. - -<source lang="pascal"> -procedure generate(n : integer, A : array of any): - if n = 1 then - output(A) - else - for i := 0; i < n - 1; i += 1 do - generate(n - 1, A) - if n is even then - swap(A[i], A[n-1]) - else - swap(A[0], A[n-1]) - end if - end for - generate(n - 1, A) - end if -</source> - -One can also write the algorithm in a non-recursive format.<ref>{{cite web|last=Sedgewick|first=Robert|title=a talk on Permutation Generation Algorithms|url=http://www.cs.princeton.edu/~rs/talks/perms.pdf}}</ref> - -<source lang="pascal"> -procedure generate(n : integer, A : array of any): - c : array of int - - for i := 0; i < n; i += 1 do - c[i] := 0 - end for - - output(A) - - i := 0; - while i < n do - if c[i] < i then - if i is even then - swap(A[0], A[i]) - else - swap(A[c[i]], A[i]) - end if - output(A) - c[i] += 1 - i := 0 - else - c[i] := 0 - i += 1 - end if - end while -</source> ==See also== '
New page size (new_size)
1659
Old page size (old_size)
4038
Size change in edit (edit_delta)
-2379
Lines added in edit (added_lines)
[]
Lines removed in edit (removed_lines)
[ 0 => false, 1 => '== Details of the algorithm ==', 2 => 'Suppose we have a permutation containing {{math|''n''}} different elements. Heap found a systematic method for choosing at each step a pair of elements to switch, in order to produce every possible permutation of these elements exactly once. Let us describe Heap's method in a recursive way. First we set a counter {{math|''i''}} to 0. Now we perform the following steps repeatedly until {{math|''i''}} is equal to {{math|''n''}}. We use the algorithm to generate the {{math|(''n''−1)!}} permutations of the first {{math|''n''−1}} elements, adjoining the last element to each of these. This generates all of the permutations that end with the last element. Then if {{math|''n''}} is odd, we switch the first element and the last one, while if {{math|''n''}} is even we can switch the {{math|''i''}}th element and the last one (there is no difference between {{math|''n''}} even and odd in the first iteration). We add one to the counter {{math|''i''}} and repeat. In each iteration, the algorithm will produce all of the permutations that end with the element that has just been moved to the "last" position. The following pseudocode outputs all permutations of a data array of length {{math|''n''}}.', 3 => false, 4 => '<source lang="pascal">', 5 => 'procedure generate(n : integer, A : array of any):', 6 => ' if n = 1 then', 7 => ' output(A)', 8 => ' else', 9 => ' for i := 0; i < n - 1; i += 1 do', 10 => ' generate(n - 1, A)', 11 => ' if n is even then', 12 => ' swap(A[i], A[n-1])', 13 => ' else', 14 => ' swap(A[0], A[n-1])', 15 => ' end if', 16 => ' end for', 17 => ' generate(n - 1, A)', 18 => ' end if', 19 => '</source>', 20 => false, 21 => 'One can also write the algorithm in a non-recursive format.<ref>{{cite web|last=Sedgewick|first=Robert|title=a talk on Permutation Generation Algorithms|url=http://www.cs.princeton.edu/~rs/talks/perms.pdf}}</ref>', 22 => false, 23 => '<source lang="pascal">', 24 => 'procedure generate(n : integer, A : array of any):', 25 => ' c : array of int', 26 => false, 27 => ' for i := 0; i < n; i += 1 do', 28 => ' c[i] := 0', 29 => ' end for', 30 => false, 31 => ' output(A)', 32 => ' ', 33 => ' i := 0;', 34 => ' while i < n do', 35 => ' if c[i] < i then', 36 => ' if i is even then', 37 => ' swap(A[0], A[i])', 38 => ' else', 39 => ' swap(A[c[i]], A[i])', 40 => ' end if', 41 => ' output(A)', 42 => ' c[i] += 1', 43 => ' i := 0', 44 => ' else', 45 => ' c[i] := 0', 46 => ' i += 1', 47 => ' end if', 48 => ' end while', 49 => '</source>' ]
Whether or not the change was made through a Tor exit node (tor_exit_node)
0
Unix timestamp of change (timestamp)
1515260623