Find lowest common ancestor in Binary Search Tree

后端 未结 6 1096
一生所求
一生所求 2021-02-10 13:57

I\'ve got the following code to find the lowest common ancestor (the lowest node that has both a and b as descendants):

public static Node LCA(Node root, Node a,          


        
6条回答
  •  清酒与你
    2021-02-10 14:23

    Does IData have the equality operator (==) defined? If not, you are just comparing the references and not the object themselves.

    This explains it fairly well: http://www.ikriv.com/en/prog/info/dotnet/ObjectEquality.html

提交回复
热议问题