%I #21 May 01 2018 02:54:32
%S 0,1,3,2,7,8,5,6,4,17,18,20,21,22,12,13,15,16,19,11,14,9,10,45,46,48,
%T 49,50,54,55,57,58,59,61,62,63,64,31,32,34,35,36,40,41,43,44,47,52,53,
%U 56,60,30,33,39,42,51,28,37,23,24,29,38,25,26,27,129,130,132,133,134
%N Permutation of natural numbers induced by Catalan automorphism *A089862 acting on the binary trees/parenthesizations encoded by A014486/A063171.
%C This automorphism effects the following transformation on the unlabeled rooted plane binary trees (letters A, B, C refer to arbitrary subtrees located on those nodes and () stands for an implied terminal node).
%C .A...B...............C...A
%C ..\./.................\./
%C ...x...C...-->.....B...x...............()..A.........A..()..
%C ....\./.............\./.................\./....-->....\./...
%C .....x...............x...................x.............x....
%C ((a . b) . c) --> (b . (c . a)) ____ (() . a) ----> (a . ())
%C See the Karttunen OEIS-Wiki link for a detailed explanation of how to obtain a given integer sequence from this definition.
%H A. Karttunen, <a href="http://oeis.org/wiki/Catalan_Automorphisms">Catalan Automorphisms</a>
%H A. Karttunen, <a href="/A089408/a089408.c.txt">C-program for computing this sequence</a>
%H <a href="/index/Per#IntegerPermutationCatAuto">Index entries for signature-permutations induced by Catalan automorphisms</a>
%o (Scheme functions implementing this automorphism on list-structures/S-expressions, both constructive (*A089862) and destructive (*A089862!) versions:)
%o (define (*A089862 s) (cond ((not (pair? s)) s) ((not (pair? (car s))) (cons (cdr s) (car s))) (else (cons (cdar s) (cons (cdr s) (caar s))))))
%o (define (*A089862! s) (cond ((pair? s) (cond ((pair? (car s)) (swap! (car s)) (robr! s) (swap! (cdr s))) (else (swap! s))))) s)
%o (define (swap! s) (let ((ex-car (car s))) (set-car! s (cdr s)) (set-cdr! s ex-car) s))
%o (define (robr! s) (let ((ex-cdr (cdr s))) (set-cdr! s (caar s)) (set-car! (car s) ex-cdr) (swap! (car s)) (swap! s) s))
%Y Row 20 of A089840. Inverse of A089860. a(n) = A089853(A069770(n)) = A069770(A089857(n)) = A069770(A074679(A069770(n))) = A057163(A089860(A057163(n))). Number of cycles: A001683 (seems to be, not checked). Number of fixed points: A019590. Max. cycle size & LCM of all cycle sizes: A089410 (in each range limited by A014137 and A014138).
%K nonn
%O 0,3
%A _Antti Karttunen_, Nov 29 2003
%E A graphical description and constructive version of Scheme-implementation added by _Antti Karttunen_, Jun 04 2011