From ef818b78d4d84ee925c2b3e71ae7b9488d6a6b24 Mon Sep 17 00:00:00 2001 From: Peter Kim Date: Wed, 8 Apr 2015 14:48:07 -0700 Subject: [PATCH] Fix Common Ancestor algorithm --- bst.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bst.html b/bst.html index a216086..d038e5a 100644 --- a/bst.html +++ b/bst.html @@ -316,7 +316,7 @@

Make this code better

if(n1 < val && n2<val){ return commonAncestor(node.left, n1, n2); } - if(n1<val && n2<val){ + if(n1>val && n2>val){ return commonAncestor(node.right, n1, n2); } console.log('lowest common ancestor value: ', val);