public bool CanFindDataToSearchFor(long dataToSearchFor) { bool canFindDataToSearchFor = false; if (Data == dataToSearchFor) { return(true); } else { if (dataToSearchFor < Data && LeftBinaryNode != null) { canFindDataToSearchFor = LeftBinaryNode.CanFindDataToSearchFor(dataToSearchFor); } if (dataToSearchFor > Data && RightBinaryNode != null) { canFindDataToSearchFor = RightBinaryNode.CanFindDataToSearchFor(dataToSearchFor); } } return(canFindDataToSearchFor); }
public bool AreChildrenNodesOnTheCorrectSideOfParent() { bool childrenNodesOnTheCorrectSideOfParent = true; if (LeftBinaryNode != null && childrenNodesOnTheCorrectSideOfParent) { if (LeftBinaryNode.Data >= Data) { childrenNodesOnTheCorrectSideOfParent = false; } if (childrenNodesOnTheCorrectSideOfParent) { childrenNodesOnTheCorrectSideOfParent = LeftBinaryNode.AreChildrenNodesOnTheCorrectSideOfParent(); } } if (RightBinaryNode != null && childrenNodesOnTheCorrectSideOfParent) { if (RightBinaryNode.Data <= Data) { childrenNodesOnTheCorrectSideOfParent = false; } if (childrenNodesOnTheCorrectSideOfParent) { childrenNodesOnTheCorrectSideOfParent = RightBinaryNode.AreChildrenNodesOnTheCorrectSideOfParent(); } } return(childrenNodesOnTheCorrectSideOfParent); }
public void SetAllData(List <long> allData) { allData.Add(Data); if (LeftBinaryNode != null) { LeftBinaryNode.SetAllData(allData); } if (RightBinaryNode != null) { RightBinaryNode.SetAllData(allData); } }