tree.add(8,3,1,6,4,7,10,14,13);console.log(tree.height());// 3// you can also use depth, which is an alias for the height functionconsole.log(tree.depth());// 3 Traversing the tree All traversal functions are generator functions, which return aGenerator. ...
compare(value: T, node:TreeNode<T>): 0 | 1 | -1 Compares certain value to the value of an undetached node in this tree using the currentisSameValueandisValueBeforeproperties. genTraversal(options?: TraversalOptions): Generator<TreeNode<T>> ...
May use tree.insertNode(...) or node.join(...) to reinstate this node to its tree. free(): TreeNode<T> Detaches (if not already detached) and disassociates this node from its associated tree. genAncestors(nGenerations?: number): Generator<TreeNode<T>> Generates parent nodes up the ...
二叉搜索树(Binary Search Tree) : 属于二叉树,其中每个节点都含有一个可以比较的键(如需要可以在键上关联值), 且每个节点的键都大于其左子树中的任意节点而小于右子树的任意节点的键。...BST 类代码如下: 1 public class BST where Tkey : IComparable 2 { 3 private Node...遍历分为广度遍历与深度遍历...
bintree = BST()withpytest.raises(TypeError): bintree.breadth_first(1)# No args/kwargswithpytest.raises(TypeError): bintree.breadth_first(None)assertisinstance(bintree.breadth_first(), types.GeneratorType) bintree.insert(5) bintree.insert(3) ...
FenwickTree.java FibonacciMinPQ.java FileIndex.java FlowEdge.java FlowNetwork.java FloydWarshall.java FordFulkerson.java FrequencyCounter.java GREP.java GabowSCC.java GaussJordanElimination.java GaussianElimination.java Genome.java GlobalMincut.java GrahamScan.java Graph.java GraphGenerator.java Grayscal...