1.2.32 • Published 5 years ago

@clarketm/superbinarytree v1.2.32

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

BinaryTree

NPM release

BinaryTree with superpowers! 💪

Individual Module Installation

Yarn

$ yarn add @clarketm/superbinarytree

Npm

$ npm install @clarketm/superbinarytree --save

API

constructor(iterable: Iterable<number>, comparator: Comparator)

Construct a BinaryTree

root: TreeNode

Get the root of the tree

height: number

Get the height of the tree

getHeight(node: TreeNode): number

Get the height of the tree at node

NameTypeAttributeDescription
nodeBinaryTreeNoderoot node

findMin(node: TreeNode): TreeNode

Find minimum value in tree

NameTypeAttributeDescription
nodeBinaryTreeNoderoot node

findMax(node: TreeNode): TreeNode

Find maximum value in tree

NameTypeAttributeDescription
nodeBinaryTreeNoderoot node

insert(value: Item)

Insert a value into the tree

NameTypeAttributeDescription
valueItemvalue to insert into the tree

search(value: Item): TreeNode

Search and retrieve a value from the tree

NameTypeAttributeDescription
valueItemvalue to search

remove(value: Item)

Remove a value from the tree

NameTypeAttributeDescription
valueItemvalue to remove

preOrder(node: TreeNode): Array<TreeNode>

Traverse the tree in preOrder traversal ordering

NameTypeAttributeDescription
nodeBinaryTreeNoderoot node

inOrder(node: TreeNode): Array<TreeNode>

Traverse the tree in inOrder traversal ordering

NameTypeAttributeDescription
nodeBinaryTreeNoderoot node

postOrder(node: TreeNode): Array<TreeNode>

Traverse the tree in postOrder traversal ordering

NameTypeAttributeDescription
nodeBinaryTreeNoderoot node

levelOrder(node: TreeNode): Array<TreeNode>

Traverse the tree in levelOrder traversal ordering

NameTypeAttributeDescription
nodeBinaryTreeNoderoot node

toArray(traversal: Traversal, flatten: boolean): Array<TreeNode|Item>

Convert the tree to an array

NameTypeAttributeDescription
traversalTraversalmethod of traversal
flattenbooleanif false return nodes; if true return only values

TreeNode

TreeNode

constructor(value: Item)

Construct a TreeNode

value: Item

Get the value of node

left: TreeNode

Get the right child node

right: TreeNode

Get the right child node

1.2.32

5 years ago

1.2.31

6 years ago

1.2.25

6 years ago

1.2.20

6 years ago

1.2.18

6 years ago

1.2.17

6 years ago

1.2.16

6 years ago

1.2.15

6 years ago

1.2.14

6 years ago

1.2.13

6 years ago

1.2.11

6 years ago

1.2.9

6 years ago

1.2.8

6 years ago

0.0.0

6 years ago