Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #1

Merged
merged 3 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions dist/cjs/ds/tree/BinaryTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
10 changes: 4 additions & 6 deletions dist/esm/ds/tree/BinaryTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
46 changes: 23 additions & 23 deletions docs/classes/index.BinarySearchTree.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>BinarySearchTree | dsajs</title>
<meta name="description" content="Documentation for dsajs">
<title>BinarySearchTree | @hwsiew/dsajs</title>
<meta name="description" content="Documentation for @hwsiew/dsajs">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../assets/css/main.css">
<script async src="../assets/js/search.js" id="search-script"></script>
Expand All @@ -23,7 +23,7 @@
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="../index.html" class="title">dsajs</a>
<a href="../index.html" class="title">@hwsiew/dsajs</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
Expand Down Expand Up @@ -52,7 +52,7 @@
<div class="container">
<ul class="tsd-breadcrumb">
<li>
<a href="../modules.html">dsajs</a>
<a href="../modules.html">@hwsiew/dsajs</a>
</li>
<li>
<a href="../modules/index.html">index</a>
Expand Down Expand Up @@ -157,7 +157,7 @@ <h3>constructor</h3>
<aside class="tsd-sources">
<p>Overrides <a href="index.BinaryTree.html">BinaryTree</a>.<a href="index.BinaryTree.html#constructor">constructor</a></p>
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinarySearchTree.ts#L34">ds/tree/BinarySearchTree.ts:34</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinarySearchTree.ts#L34">ds/tree/BinarySearchTree.ts:34</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -183,7 +183,7 @@ <h3>_compare<wbr>Fn</h3>
<div class="tsd-signature tsd-kind-icon">_compare<wbr>Fn<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">CompareFunction</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinarySearchTree.ts#L28">ds/tree/BinarySearchTree.ts:28</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinarySearchTree.ts#L28">ds/tree/BinarySearchTree.ts:28</a></li>
</ul>
</aside>
</section>
Expand All @@ -194,7 +194,7 @@ <h3>_root</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="index.BinaryTree.html">BinaryTree</a>.<a href="index.BinaryTree.html#_root">_root</a></p>
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinaryTree.ts#L5">ds/tree/BinaryTree.ts:5</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinaryTree.ts#L5">ds/tree/BinaryTree.ts:5</a></li>
</ul>
</aside>
</section>
Expand All @@ -211,7 +211,7 @@ <h3>root</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinaryTree.ts#L35">ds/tree/BinaryTree.ts:35</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinaryTree.ts#L35">ds/tree/BinaryTree.ts:35</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -236,7 +236,7 @@ <h3>delete</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinarySearchTree.ts#L94">ds/tree/BinarySearchTree.ts:94</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinarySearchTree.ts#L94">ds/tree/BinarySearchTree.ts:94</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -267,7 +267,7 @@ <h3>height</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="index.BinaryTree.html">BinaryTree</a>.<a href="index.BinaryTree.html#height">height</a></p>
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinaryTree.ts#L45">ds/tree/BinaryTree.ts:45</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinaryTree.ts#L45">ds/tree/BinaryTree.ts:45</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -296,7 +296,7 @@ <h3>in<wbr>Order</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="index.BinaryTree.html">BinaryTree</a>.<a href="index.BinaryTree.html#inOrder">inOrder</a></p>
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinaryTree.ts#L88">ds/tree/BinaryTree.ts:88</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinaryTree.ts#L88">ds/tree/BinaryTree.ts:88</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -319,7 +319,7 @@ <h3>insert</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinarySearchTree.ts#L51">ds/tree/BinarySearchTree.ts:51</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinarySearchTree.ts#L51">ds/tree/BinarySearchTree.ts:51</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -350,7 +350,7 @@ <h3>is<wbr>Balance</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="index.BinaryTree.html">BinaryTree</a>.<a href="index.BinaryTree.html#isBalance">isBalance</a></p>
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinaryTree.ts#L215">ds/tree/BinaryTree.ts:215</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinaryTree.ts#L215">ds/tree/BinaryTree.ts:215</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -373,7 +373,7 @@ <h3>is<wbr>Complete</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="index.BinaryTree.html">BinaryTree</a>.<a href="index.BinaryTree.html#isComplete">isComplete</a></p>
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinaryTree.ts#L235">ds/tree/BinaryTree.ts:235</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinaryTree.ts#L235">ds/tree/BinaryTree.ts:235</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -396,7 +396,7 @@ <h3>is<wbr>Empty</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="index.BinaryTree.html">BinaryTree</a>.<a href="index.BinaryTree.html#isEmpty">isEmpty</a></p>
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinaryTree.ts#L79">ds/tree/BinaryTree.ts:79</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinaryTree.ts#L79">ds/tree/BinaryTree.ts:79</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -419,7 +419,7 @@ <h3>is<wbr>Full</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="index.BinaryTree.html">BinaryTree</a>.<a href="index.BinaryTree.html#isFull">isFull</a></p>
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinaryTree.ts#L160">ds/tree/BinaryTree.ts:160</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinaryTree.ts#L160">ds/tree/BinaryTree.ts:160</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -442,7 +442,7 @@ <h3>is<wbr>Perfect</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="index.BinaryTree.html">BinaryTree</a>.<a href="index.BinaryTree.html#isPerfect">isPerfect</a></p>
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinaryTree.ts#L183">ds/tree/BinaryTree.ts:183</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinaryTree.ts#L183">ds/tree/BinaryTree.ts:183</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -465,7 +465,7 @@ <h3>post<wbr>Order</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="index.BinaryTree.html">BinaryTree</a>.<a href="index.BinaryTree.html#postOrder">postOrder</a></p>
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinaryTree.ts#L136">ds/tree/BinaryTree.ts:136</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinaryTree.ts#L136">ds/tree/BinaryTree.ts:136</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -489,7 +489,7 @@ <h3>pre<wbr>Order</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="index.BinaryTree.html">BinaryTree</a>.<a href="index.BinaryTree.html#preOrder">preOrder</a></p>
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinaryTree.ts#L112">ds/tree/BinaryTree.ts:112</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinaryTree.ts#L112">ds/tree/BinaryTree.ts:112</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -512,7 +512,7 @@ <h3>search</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinarySearchTree.ts#L74">ds/tree/BinarySearchTree.ts:74</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinarySearchTree.ts#L74">ds/tree/BinarySearchTree.ts:74</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -542,7 +542,7 @@ <h3>size</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="index.BinaryTree.html">BinaryTree</a>.<a href="index.BinaryTree.html#size">size</a></p>
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinaryTree.ts#L64">ds/tree/BinaryTree.ts:64</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinaryTree.ts#L64">ds/tree/BinaryTree.ts:64</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -565,7 +565,7 @@ <h3><span class="tsd-flag ts-flagStatic">Static</span> is<wbr>Subtree</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="index.BinaryTree.html">BinaryTree</a>.<a href="index.BinaryTree.html#isSubtree">isSubtree</a></p>
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinaryTree.ts#L281">ds/tree/BinaryTree.ts:281</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinaryTree.ts#L281">ds/tree/BinaryTree.ts:281</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -597,7 +597,7 @@ <h3><span class="tsd-flag ts-flagStatic">Static</span> is<wbr>Symmetric</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="index.BinaryTree.html">BinaryTree</a>.<a href="index.BinaryTree.html#isSymmetric">isSymmetric</a></p>
<ul>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/2c45e87/src/ds/tree/BinaryTree.ts#L255">ds/tree/BinaryTree.ts:255</a></li>
<li>Defined in <a href="https://github.com/hwsiew/dsa.js/blob/6aa95fb/src/ds/tree/BinaryTree.ts#L255">ds/tree/BinaryTree.ts:255</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down
Loading