complete-k-ary-tree

1.1.3 • Public • Published

complete-k-ary-tree

https://www.cs.auckland.ac.nz/software/AlgAnim/n_ary_trees.html
n-ary trees (or n-way trees)
Trees in which each node may have up to n children.
https://en.wikipedia.org/wiki/K-ary_tree

IsParent=floor.((i-1)/k)

pls see source/test.js

[ { parent: 'prependChild', key: 'SyzeD3MHK_Z', depth: 0, index: 0 },
  { parent: 'SyzeD3MHK_Z', key: 'BkmD3MHKuZ', depth: 1, index: 1 },
  { parent: 'SyzeD3MHK_Z', key: 'BkWxPhMHF_b', depth: 1, index: 2 },
  { parent: 'BkWxPhMHF_b', key: 'HyelwhMBY_-', depth: 2, index: 17 },
  { parent: 'HyelwhMBY_-', key: 'ryyev3fSt_-', depth: 3, index: 137 },
  { parent: 'SyzeD3MHK_Z', key: 'HyCwnMSYdb', depth: 1, index: 3 },
  { parent: 'HyCwnMSYdb', key: 'B16w3GSF_Z', depth: 2, index: 25 },
  { parent: 'SyzeD3MHK_Z', key: 'HyxD3frFd-', depth: 1, index: 4 },
  { parent: 'HyxD3frFd-', key: 'SyD2zHYdW', depth: 2, index: 33 },
  { parent: 'SyzeD3MHK_Z', key: 'r1zD3GSFOb', depth: 1, index: 5 },
  { parent: 'r1zD3GSFOb', key: 'SJ-w3GSY_Z', depth: 2, index: 41 },
  { parent: 'SyzeD3MHK_Z', key: 'rkhDhMHYdZ', depth: 1, index: 6 },
  { parent: 'rkhDhMHYdZ', key: 'Byow3GBFdb', depth: 2, index: 49 },
  { parent: 'Byow3GBFdb', key: 'BJcDhzrt_-', depth: 3, index: 393 },
  { parent: 'SyzeD3MHK_Z', key: 'ry8wnMBFu-', depth: 1, index: 7 },
  { parent: 'ry8wnMBFu-', key: 'SJHPhzHYd-', depth: 2, index: 57 },
  { parent: 'SJHPhzHYd-', key: 'ByEPnMBtu-', depth: 3, index: 457 },
  { parent: 'SyzeD3MHK_Z', key: 'SytD2MBKuZ', depth: 1, index: 8 },
  { parent: 'SytD2MBKuZ', key: 'rJdP3zHt_b', depth: 2, index: 65 },
  { parent: 'rJdP3zHt_b', key: 'SJPw3zBYuW', depth: 3, index: 521 } ]

Readme

Keywords

Package Sidebar

Install

npm i complete-k-ary-tree

Weekly Downloads

2

Version

1.1.3

License

ISC

Last publish

Collaborators

  • bjk543