Notoriously Punctual Manatee

    ts-binary-tree
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0 • Public • Published

    初始化二叉树

    let binaryTree = new InitBinaryTree()

    插入数组

    let nodes = [8, 3, 10, 1, 6, 14, 4, 7, 13]
    nodes.forEach((item) => {
        binaryTree.insert(item)
    })

    中序遍历,升序

    binaryTree.inOrderTraversal((key) => {
    
      console.log(key)
    
    }, 'up')

    中序遍历,降序

    binaryTree.inOrderTraversal((key) => {
    
      console.log(key)
    
    }, 'down')

    前序遍历

    binaryTree.prevOnNextTraversal((key) => {
    
      console.log(key)
    
    }, 'prev')
    

    后序遍历

    binaryTree.prevOnNextTraversal((key) => {
    
      console.log(key)
    
    }, 'next')

    查找最小值

    let min = binaryTree.min()

    查找最大值

    let max = binaryTree.max()

    查询指定值

    let search = binaryTree.search(1)

    移除指定值

    binaryTree.remove(1)

    Install

    npm i ts-binary-tree

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    8.37 kB

    Total Files

    5

    Last publish

    Collaborators

    • lihaixiang0034