A346914 Irregular triangle read by rows where each row is the vertex parent array of a rooted forest in Knuth's form of Beyer and Hedetniemi's iteration.
0, 0, 1, 0, 0, 0, 1, 2, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 2, 3, 0, 1, 2, 2, 0, 1, 2, 1, 0, 1, 2, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 1, 2, 3, 3, 0, 1, 2, 3, 2, 0, 1, 2, 3, 1, 0, 1, 2, 3, 0, 0, 1, 2, 2, 2, 0, 1, 2, 2, 1
Offset: 2
Examples
Triangle begins: v=1 v=2 v=3 v=4 n=2: 0 n=3: 0, 1 n=4: 0, 0 n=5: 0, 1, 2 n=6: 0, 1, 1 n=7: 0, 1, 0 n=8: 0, 0, 0 n=9: 0, 1, 2, 3 n=10: 0, 1, 2, 2 Row n=1156 is 0,1,2,1,0,5,5,0,8 which is forest: roots 1 5 8 vertex 1 2 3 4 5 6 7 8 9 |\ |\ | vpar 0,1,2,1,0,5,5,0,8 children 2 4 6 7 9 | 3
Links
- Kevin Ryde, Table of n, a(n) for rows 2 to 1205 (forests <= 9 vertices), flattened
- Donald E. Knuth, The Art of Computer Programming, Volume 4A, Combinatorial Algorithms, Part 1, section 7.2.1.6, algorithm O (Oriented forests). Also in Pre-Fascicle 4A, Draft of Section 7.2.1.6, Generating All Trees, page 22.
- Kevin Ryde, PARI/GP Code for Iterating
Programs
-
Mathematica
(* Uses Algorithm O from Knuth's TAOCP section 7.2.1.6 *) olist[m_] := Block[{p = Range[m] - 1, j, d, k}, Reap[ While[True, Sow[p]; If[p[[m]] > 0, p[[m]] = p[[p[[m]]]], k = m; While[k > 0 && p[[--k]] == 0]; If[k == 0, Break[]]; j = p[[k]]; d = k-- -j; While[++k <= m, p[[k]] = If[p[[k-d]] == p[[j]], p[[j]], p[[k-d]] + d]] ]]][[2, 1]]]; Map[Delete[#, 0] &, Array[olist, 5]] (* Paolo Xausa, Apr 05 2024 *)
-
PARI
\\ See links.
Comments