cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-2 of 2 results.

A378496 Inverse of permutation in A380856.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 9, 11, 12, 14, 13, 15, 16, 20, 17, 21, 18, 22, 19, 23, 24, 28, 25, 29, 26, 30, 27, 31, 32, 33, 40, 41, 34, 35, 42, 43, 36, 37, 44, 45, 38, 39, 46, 47, 48, 49, 56, 57, 50, 51, 58, 59, 52, 53, 60, 61, 54, 55, 62, 63, 64, 65, 66, 67
Offset: 0

Views

Author

Alois P. Heinz, Feb 14 2025

Keywords

Comments

Permutation of the nonnegative integers A001477 with inverse permutation A380856.

Crossrefs

A379905 Rank of the permutation resulting from a pre-order traversal of a binary tree which is complete except for the final row and has vertices numbered 0 to n-1.

Original entry on oeis.org

0, 0, 0, 1, 3, 8, 30, 222, 1302, 8442, 63570, 545473, 5249163, 55941128, 653682990, 8597126190, 117809490990, 1730350233390, 27183297753390, 454752069221550, 8070074352360750, 151403473011001710, 2993918729983972590, 62232717584055513822, 1356493891878893498262
Offset: 1

Views

Author

DarĂ­o Clavijo, Jan 05 2025

Keywords

Comments

Permutations are ranked in lexicographic order with the identity permutation as rank 0.
The tree is complete when n = 2^k - 1.
Also the tree has A070939(n) levels and the tree height is floor(log_2(n)).

Examples

			For n = 5, the tree is
      0
     / \
    1   2
   / \
  3   4
Pre-order traversal is vertices {0,1,3,4,2} and among the permutations of 0..4 this has rank a(5) = 3.
		

Crossrefs

Programs

  • Mathematica
    a[n_Integer]:=Module[{res={}, data, len}, data=Range[n]; len=Length[data]; Which[MemberQ[{1, 2, 3}, n], 0, n==4, 1,True, DepthFirstScan[TreeGraph[Table[Floor[j/2]->j, {j, 2, len}]], 1,{"PrevisitVertex"->(AppendTo[res, #]&)}]; ResourceFunction["PermutationIndex"][res]-1]]; a/@Range[1, 25] (* Shenghui Yang, Feb 15 2025 *)
  • Python
    from binarytree import Node, build
    from sympy.combinatorics import Permutation
    a = lambda n: Permutation([node.value for node in build(list(range(n))).preorder]).rank()
    print([a(n) for n in range(1,26)])
Showing 1-2 of 2 results.