Logo

Greetings from The On-Line Encyclopedia of Integer Sequences!

Hints

Search: id:A153240
Displaying 1-1 of 1 results found. page 1
     Format: long | short | internal | text      Sort: relevance | references | number      Highlight: on | off
A153240 Balance of general trees as ordered by A014486, variant A. +0
4
0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1, 0, 2, 2, -1, 0, -2, 0, 1, -2, -1, 0, 0, 0, 1, 1, 2, 2, -1, 1, 0, 3, 3, 0, 3, 3, 3, -1, 0, -1, 1, 1, -2, -1, -3, 0, 1, -3, 0, 2, 2, -2, -1, -3, -1, 0, -3, -2, 0, 1, -3, -2, -1, 0, 0, 0, 1, 1, 2, 2, 0, 2, 2, 3, 3, 2, 3, 3, 3, -1, 0, 0, 2, 2, -2, 1, 0, 4, 4, 1, 4 (list; graph; listen)
OFFSET

0,13

COMMENT

This differs from variant A153241 only in that if the degree of the tree is odd (i.e. A057515(n) = 1 mod 2), then the balance of the center-subtree is always taken into account.

Note that for all n, Sum_{i=A014137(n)}^A014138(n) a(i) = 0.

LINKS

A. Karttunen, Table of n, a(n) for n = 0..2055

EXAMPLE

A014486(25) encodes the following general tree:

......o

......|

o.o...o.o

.\.\././

....*..

which consists of four subtrees, of which the second from right is one larger than the others, so we have a(25) = (0+1)-(0+0) = 1.

PROGRAM

(MIT Scheme:)

(define (A153240 n) (gentree-deep-balance (A014486->parenthesization (A014486 n))))

(define (gentree-deep-balance l) (let ((r (reverse l))) (let loop ((i 0) (j (- (length l) 1)) (l l) (r r) (z 0)) (cond ((= i j) (+ z (gentree-deep-balance (car l)))) ((> i j) z) (else (loop (+ i 1) (- j 1) (cdr l) (cdr r) (+ z (- (count-pars (car r)) (count-pars (car l))))))))))

(define (count-pars a) (cond ((not (pair? a)) 0) (else (+ 1 (count-pars (car a)) (count-pars (cdr a))))))

CROSSREFS

Differs from variant A153241 for the first time at n=268, where A153241(268) = 1, while a(268)=2. Note that (A014486->parenthesization (A014486 268)) = (() (() (())) (())). a(A061856(n)) = 0 for all n. Cf. also A153239.

Sequence in context: A133624 A030110 A083570 this_sequence A153241 A096830 A141647

Adjacent sequences: A153237 A153238 A153239 this_sequence A153241 A153242 A153243

KEYWORD

sign

AUTHOR

Antti Karttunen (His-Firstname.His-Surname(AT)gmail.com), Dec 21 2008

page 1

Search completed in 0.002 seconds

Lookup | Welcome | Find friends | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Puzzles | Hot | Classics
More pages | Superseeker | Maintained by N. J. A. Sloane (njas@research.att.com)

Last modified November 27 22:38 EST 2009. Contains 167602 sequences.


AT&T Labs Research