Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #4 Mar 31 2012 13:21:17
%S 0,0,1,-1,2,2,0,-2,-2,3,3,3,3,3,1,1,-1,-3,-3,-1,-3,-3,-3,4,4,4,4,4,4,
%T 4,4,4,4,4,4,4,4,2,2,2,2,2,0,0,-2,-4,-4,-2,-4,-4,-4,0,0,-2,-4,-4,-2,
%U -4,-4,-4,-2,-4,-4,-4,-4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
%N Balance of binary trees as ordered by A014486: number of vertices in the right subtree minus number of vertices in the left subtree.
%C Note that for all n, Sum_{i=A014137(n)}^A014138(n) a(i) = 0.
%H A. Karttunen, <a href="/A153239/b153239.txt">Table of n, a(n) for n = 0..2055</a>
%e A014486(19) encodes the following binary tree:
%e .\/
%e ..\/.\/
%e ...\./
%e Because the subtree at the right contains just one internal node and the subtree at the left contains two, we have a(19) = 1-2 = -1.
%o (MIT Scheme:)
%o (define (A153239 n) (let ((s (A014486->parenthesization (A014486 n)))) (if (null? s) 0 (- (count-pars (cdr s)) (count-pars (car s))))))
%o (define (count-pars a) (cond ((not (pair? a)) 0) (else (+ 1 (count-pars (car a)) (count-pars (cdr a))))))
%Y A153243 gives the positions of zeros. Cf. A153240, A153241.
%K sign
%O 0,5
%A _Antti Karttunen_, Dec 21 2008