The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A257676 Permutation of nonnegative integers obtained by traversing the tendrils (finite side-trees) of the binary beanstalk in depth-first order, with also each number in the infinite trunk visited, but only after its sister branch has been traversed first. 4

%I

%S 0,1,2,3,5,4,6,7,9,8,10,12,13,11,14,15,17,16,18,20,21,19,22,24,25,28,

%T 29,23,27,26,30,31,33,32,34,36,37,35,38,40,41,44,45,39,43,42,47,50,54,

%U 58,59,55,51,46,48,49,52,53,56,60,61,57,62,63,65,64,66,68,69,67,70,72,73,76,77,71,75,74,79,82,86,90,91,87,83,78,80,81

%N Permutation of nonnegative integers obtained by traversing the tendrils (finite side-trees) of the binary beanstalk in depth-first order, with also each number in the infinite trunk visited, but only after its sister branch has been traversed first.

%H Antti Karttunen, <a href="/A257676/b257676.txt">Table of n, a(n) for n = 0..16384</a>

%H Antti Karttunen, <a href="/A257676/a257676.txt">Same Scheme-function as in Program section, but indented and commented properly</a>

%H Paul Tek, <a href="/A179016/a179016.png">Illustration of how natural numbers in range 0 .. 133 are organized as a binary tree in the binary beanstalk</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%F a(0) = 0; a(1) = 1;

%F otherwise set prev = a(n-1);

%F if A213719(prev) = 1 [prev is one of the terms in A179016]

%F then if A213719(A213723(prev)) = 0, a(n) = A213723(prev),

%F else a(n) = A213724(prev);

%F else if(A213723(prev) > 0), a(n) = A213723(prev),

%F else if(A213724(prev) > 0), a(n) = A213724(prev),

%F otherwise,

%F a(n) = {the first unvisited node of binary beanstalk tree found when we backtrack out of a finite branch just traversed in depth-first order}.

%F Other identities and observations:

%F If a(n-1) is an even term of A055938 then a(n) = a(n-1)+1.

%e Please look at Paul Tek's illustration: We start at root, 0, go up to 1, visit its left child 2 (which is a leaf), before proceeding the infinite trunk (A179016) to 3, then visit first the leaf 5 at the right hand side, before proceeding the infinite trunk to 4, then visit the leaf 6 at the left hand side, before proceeding the infinite trunk right to 7, from which we first visit the leaf 9 at the right hand side, before proceeding the infinite trunk to 8 at the left hand side. Thus we have ten initial terms of the sequence: 0, 1, 2, 3, 5, 4, 6, 7, 9, 8, ...

%e From 8 we proceed first to the left 10, because it is not a part of the infinite trunk, and we traverse a finite side-tree ("tendril") of three nodes in order 10, 12, 13, only after which we proceed the infinite trunk to the right, to 11, thus we have the next four terms of the sequence 10, 12, 13, 11.

%o (Scheme, with defineperm1-macro from _Antti Karttunen_'s IntSeq-library)

%o (defineperm1 (A257676 n) (if (<= n 1) n (let ((prev (A257676 (- n 1)))) (cond ((= 1 (A213719 prev)) (if (zero? (A213719 (A213723 prev))) (A213723 prev) (A213724 prev))) ((not (zero? (A213723 prev))) (A213723 prev)) ((not (zero? (A213724 prev))) (A213724 prev)) (else (let loop ((prev prev) (back (A011371 prev))) (cond ((= 1 (A213719 back)) (if (zero? (A213719 (A213723 back))) (A213724 back) (A213723 back))) ((and (even? prev) (not (zero? (A213724 back)))) (A213724 back)) (else (loop back (A011371 back))))))))))

%o ;; Please see the attached text-file for the same code better indented and documented.

%Y Inverse: A257677.

%Y Fixed points: A257678.

%Y Cf. A011371, A055938, A179016, A213719, A213723, A213724, A213725, A213727, A213730.

%Y Cf. also A218252.

%K nonn

%O 0,3

%A _Antti Karttunen_, May 04 2015

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified August 1 07:45 EDT 2021. Contains 346384 sequences. (Running on oeis4.)