From 6aa95fb09c2f5b6ca2460ad76147530afb2e8a6a Mon Sep 17 00:00:00 2001 From: hwsiew Date: Wed, 25 Aug 2021 12:27:40 +0800 Subject: [PATCH 1/3] Fix tree isfull --- src/ds/tree/BinaryTree.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ds/tree/BinaryTree.ts b/src/ds/tree/BinaryTree.ts index 0b1ee5f..b7494b9 100644 --- a/src/ds/tree/BinaryTree.ts +++ b/src/ds/tree/BinaryTree.ts @@ -163,12 +163,12 @@ export default class BinaryTree { if(!node) return true; - // if a node has both left and right node - if(node.left && node.right) return true; - // if a node has either left or right node - if(node.left || node.right) return false; - return verify(node.left) && verify(node.right); + if(!node.left && !node.right) return true; + + if(node.left && node.right) return verify(node.left) && verify(node.right); + + return false; } From ded67d8fddb81d1675ec9f1c3ab19d184fc5abbc Mon Sep 17 00:00:00 2001 From: hwsiew Date: Wed, 25 Aug 2021 12:29:10 +0800 Subject: [PATCH 2/3] Update build and docs file --- dist/cjs/ds/tree/BinaryTree.js | 10 +++--- dist/esm/ds/tree/BinaryTree.js | 10 +++--- docs/classes/index.BinarySearchTree.html | 46 ++++++++++++------------ docs/classes/index.BinaryTree.html | 38 ++++++++++---------- docs/classes/index.CircularQueue.html | 30 ++++++++-------- docs/classes/index.Graph.html | 24 ++++++------- docs/classes/index.Heap.html | 30 ++++++++-------- docs/classes/index.LinkedList.html | 32 ++++++++--------- docs/classes/index.MapMap.html | 24 ++++++------- docs/classes/index.PriorityQueue.html | 22 ++++++------ docs/classes/index.Queue.html | 22 ++++++------ docs/classes/index.Stack.html | 22 ++++++------ docs/index.html | 9 ++--- docs/modules.html | 8 ++--- docs/modules/algo_search.html | 10 +++--- docs/modules/algo_sort.html | 20 +++++------ docs/modules/index.html | 8 ++--- docs/modules/utils_types.html | 14 ++++---- 18 files changed, 188 insertions(+), 191 deletions(-) diff --git a/dist/cjs/ds/tree/BinaryTree.js b/dist/cjs/ds/tree/BinaryTree.js index 3b27873..bcf3b56 100644 --- a/dist/cjs/ds/tree/BinaryTree.js +++ b/dist/cjs/ds/tree/BinaryTree.js @@ -130,13 +130,11 @@ var BinaryTree = /** @class */ (function () { var verify = function (node) { if (!node) return true; - // if a node has both left and right node - if (node.left && node.right) + if (!node.left && !node.right) return true; - // if a node has either left or right node - if (node.left || node.right) - return false; - return verify(node.left) && verify(node.right); + if (node.left && node.right) + return verify(node.left) && verify(node.right); + return false; }; return verify(this._root); }; diff --git a/dist/esm/ds/tree/BinaryTree.js b/dist/esm/ds/tree/BinaryTree.js index b766694..c4283d3 100644 --- a/dist/esm/ds/tree/BinaryTree.js +++ b/dist/esm/ds/tree/BinaryTree.js @@ -125,13 +125,11 @@ var BinaryTree = /** @class */ (function () { var verify = function (node) { if (!node) return true; - // if a node has both left and right node - if (node.left && node.right) + if (!node.left && !node.right) return true; - // if a node has either left or right node - if (node.left || node.right) - return false; - return verify(node.left) && verify(node.right); + if (node.left && node.right) + return verify(node.left) && verify(node.right); + return false; }; return verify(this._root); }; diff --git a/docs/classes/index.BinarySearchTree.html b/docs/classes/index.BinarySearchTree.html index 273dae3..800ef1e 100644 --- a/docs/classes/index.BinarySearchTree.html +++ b/docs/classes/index.BinarySearchTree.html @@ -3,8 +3,8 @@ - BinarySearchTree | dsajs - + BinarySearchTree | @hwsiew/dsajs + @@ -23,7 +23,7 @@
  • Preparing search index...
  • The search index is not available
  • - dsajs + @hwsiew/dsajs
    @@ -52,7 +52,7 @@
    - dsajs + @hwsiew/dsajs
    @@ -52,7 +52,7 @@
    - dsajs + @hwsiew/dsajs
    @@ -52,7 +52,7 @@
    - dsajs + @hwsiew/dsajs
    @@ -52,7 +52,7 @@
    - dsajs + @hwsiew/dsajs
    @@ -52,7 +52,7 @@
    - dsajs + @hwsiew/dsajs
    @@ -52,7 +52,7 @@
    - dsajs + @hwsiew/dsajs
    @@ -52,7 +52,7 @@
    - dsajs + @hwsiew/dsajs
    @@ -52,7 +52,7 @@
    - dsajs + @hwsiew/dsajs
    @@ -52,7 +52,7 @@
    - dsajs + @hwsiew/dsajs
    @@ -52,7 +52,7 @@
    - dsajs + @hwsiew/dsajs
    @@ -50,7 +50,7 @@
    -

    dsajs

    +

    @hwsiew/dsajs

    diff --git a/docs/modules/algo_search.html b/docs/modules/algo_search.html index 659658b..0e67c1d 100644 --- a/docs/modules/algo_search.html +++ b/docs/modules/algo_search.html @@ -3,8 +3,8 @@ - algo/search | dsajs - + algo/search | @hwsiew/dsajs + @@ -23,7 +23,7 @@
  • Preparing search index...
  • The search index is not available
  • - dsajs + @hwsiew/dsajs
    @@ -52,7 +52,7 @@
    • - dsajs + @hwsiew/dsajs
    • algo/search @@ -90,7 +90,7 @@

      binarySearch

    • Parameters

      diff --git a/docs/modules/algo_sort.html b/docs/modules/algo_sort.html index 5e6859c..4aa00b9 100644 --- a/docs/modules/algo_sort.html +++ b/docs/modules/algo_sort.html @@ -3,8 +3,8 @@ - algo/sort | dsajs - + algo/sort | @hwsiew/dsajs + @@ -23,7 +23,7 @@
    • Preparing search index...
    • The search index is not available
    - dsajs + @hwsiew/dsajs
    @@ -52,7 +52,7 @@
    - dsajs + @hwsiew/dsajs
    @@ -52,7 +52,7 @@
    • - dsajs + @hwsiew/dsajs
    • index diff --git a/docs/modules/utils_types.html b/docs/modules/utils_types.html index 4cb00ec..ee747f5 100644 --- a/docs/modules/utils_types.html +++ b/docs/modules/utils_types.html @@ -3,8 +3,8 @@ - utils/types | dsajs - + utils/types | @hwsiew/dsajs + @@ -23,7 +23,7 @@
    • Preparing search index...
    • The search index is not available
    - dsajs + @hwsiew/dsajs
    @@ -52,7 +52,7 @@
    • - dsajs + @hwsiew/dsajs
    • utils/types @@ -88,7 +88,7 @@

      BinarySearchCompareFunction

      BinarySearchCompareFunction: (a: any) => number
      @@ -129,7 +129,7 @@

      CompareFunctionBoolean

      CompareFunctionBoolean: (a: any, b: any) => boolean
      @@ -174,7 +174,7 @@

      CompareFunctionNumber

      CompareFunctionNumber: (a: any, b: any) => number
      From e948c406760515a4a3206936b5e0215dfbde9f16 Mon Sep 17 00:00:00 2001 From: hwsiew Date: Wed, 25 Aug 2021 12:29:36 +0800 Subject: [PATCH 3/3] Update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 191b9e5..0e7a63d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hwsiew/dsajs", - "version": "0.11.0", + "version": "0.11.1", "description": "Data structure and algorithms implementation in Javascript", "main": "./dist/cjs/index.js", "module": "./dist/esm/index.js",