Comments on: Lowest Common Ancestor in Binary Search Tree https://demo.ritambhara.in/lowest-common-ancestor-in-binary-search-tree/ Coding / System Design Interviews Fri, 20 Sep 2019 04:15:43 +0000 hourly 1 https://wordpress.org/?v=6.7.2 By: Gaurav Dixit https://demo.ritambhara.in/lowest-common-ancestor-in-binary-search-tree/#comment-1823 Fri, 20 Sep 2019 04:15:43 +0000 http://www.ritambhara.in/?p=1456#comment-1823 This line
IF (value_at_root b) OR (value_at_root < b AND value_at_root < a)
RETURN root
should be like
IF (value_at_root
b) OR (value_at_root a)
RETURN root

]]>
By: Alex https://demo.ritambhara.in/lowest-common-ancestor-in-binary-search-tree/#comment-1822 Thu, 20 Nov 2014 10:56:33 +0000 http://www.ritambhara.in/?p=1456#comment-1822 public void listar(int valorClave1, int valorClave2)throws IOException, volcará por la salida
estándar la información de los registros del archivo de datos cuyo campo numReg se encuentre
en el intervalo [valorClave1, valorClave2] (ambos inclusive), ordenados por el campo numReg.
En la implementación de este método se deberá evitar visitar páginas del árbol B que con toda
seguridad NO contienen claves que se encuentren dentro del intervalo [valorClave1,
valorClave2].

]]>
By: Greg Skinner https://demo.ritambhara.in/lowest-common-ancestor-in-binary-search-tree/#comment-1821 Fri, 09 May 2014 01:42:21 +0000 http://www.ritambhara.in/?p=1456#comment-1821 Shouldn't the first IF statement of the Algorithm be:
IF (value_at_root < a AND value_at_root > b) OR (value_at_root > a AND value_at_root < b)

]]>
By: Sophia Feng https://demo.ritambhara.in/lowest-common-ancestor-in-binary-search-tree/#comment-1820 Sat, 04 Jan 2014 04:21:28 +0000 http://www.ritambhara.in/?p=1456#comment-1820 In the Algorithm part, IF (value_at_root < a AND value_at_root < b) and ELSE should be switched

]]>
By: aaditya https://demo.ritambhara.in/lowest-common-ancestor-in-binary-search-tree/#comment-1819 Sat, 29 Jun 2013 07:37:51 +0000 http://www.ritambhara.in/?p=1456#comment-1819 In reply to aaditya.

what in case of a=1 and b=4
can a node be ancestor of its own
what wl be the ancestor of a=1 and b=4

]]>
By: aaditya https://demo.ritambhara.in/lowest-common-ancestor-in-binary-search-tree/#comment-1818 Sat, 29 Jun 2013 07:36:41 +0000 http://www.ritambhara.in/?p=1456#comment-1818 In reply to Kamal Rawat.

pls correct it
it create lots of confusion

]]>
By: Kamal Rawat https://demo.ritambhara.in/lowest-common-ancestor-in-binary-search-tree/#comment-1817 Wed, 17 Apr 2013 03:09:56 +0000 http://www.ritambhara.in/?p=1456#comment-1817 In reply to hello.

Actually it can be debated and should be defined.. And that’s how it should be during the interview.. We should ask the interviewer what does he expect in such cases..

]]>
By: Kamal Rawat https://demo.ritambhara.in/lowest-common-ancestor-in-binary-search-tree/#comment-1816 Wed, 17 Apr 2013 03:08:42 +0000 http://www.ritambhara.in/?p=1456#comment-1816 In reply to Steven.

You are right.. will need to put a check that if data of node == either a or b then stop there and return that

]]>
By: hello https://demo.ritambhara.in/lowest-common-ancestor-in-binary-search-tree/#comment-1815 Tue, 16 Apr 2013 20:14:29 +0000 http://www.ritambhara.in/?p=1456#comment-1815 In reply to Steven.

it should return 5

]]>
By: hello https://demo.ritambhara.in/lowest-common-ancestor-in-binary-search-tree/#comment-1814 Tue, 16 Apr 2013 20:14:01 +0000 http://www.ritambhara.in/?p=1456#comment-1814 it should return 5

]]>