Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public void SetAllData(List <long> allData)
        {
            allData.Add(Data);
            if (LeftBinaryNode != null)
            {
                LeftBinaryNode.SetAllData(allData);
            }

            if (RightBinaryNode != null)
            {
                RightBinaryNode.SetAllData(allData);
            }
        }