Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #10 Mar 07 2020 04:09:57
%S 0,1,1,2,3,4,4,5,6,6,7,8,9,9,10,10,11,12,13,13,14,15,15,16,16,17,18,
%T 19,19,20,21,22,22,23,24,24,25,25,26,27,28,28,29,29,30,31,32,32,33,34,
%U 35,35,36,37,37,38,38,39,40,41,41,42,43,43,44,44,45,46,47,47
%N Found by taking the tree defined by the Hofstadter H-sequence (A005374), mirroring it left to right and relabeling the nodes so they increase left to right. a(n) is the parent node of node n in the tree so constructed.
%D D. R. Hofstadter, Goedel, Escher, Bach: an Eternal Golden Braid, Basic Books, 1999, p. 137.
%H David Fifield <a href="/A154951/b154951.txt">Table of n, a(n) for n = 0..10000</a>
%o (Python) # Emulate a breadth-first traversal of the "flip"
%o # of the tree defined by the Hofstadter H-sequence.
%o def hflip_iter():
%o yield 0
%o yield 1
%o # Start on the first node of a left branch, parent node is 1.
%o queue = [(1, 1)]
%o n = 2
%o while True:
%o parent, state = queue.pop(0)
%o yield parent
%o if state == 0:
%o # Root node. Add the two children.
%o queue.append((n, 1))
%o queue.append((n, 0))
%o elif state == 1:
%o # First node on left branch. Add the second node.
%o queue.append((n, 2))
%o elif state == 2:
%o # Second node on left branch. Add a new root.
%o queue.append((n, 0))
%o n += 1
%o i = hflip_iter()
%o for n in range(0, 10001):
%o print("%d %d" % (n, next(i)))
%Y Cf. A005374, A123070.
%K nonn
%O 0,4
%A _David Fifield_, Jan 17 2009