chapter_003/src/main/java/ru/job4j/tree/BST.java
private boolean findAndSetParentNode(Node parentNode, Node newNode) {
        if (newNode.value.compareTo(parentNode.value) == -1) {
            if (parentNode.leftNode == null)
                parentNode.leftNode = newNode;
            else
                findAndSetParentNode(parentNode.leftNode, newNode);
        } else {
            if (parentNode.rightNode == null)
                parentNode.rightNode = newNode;
            else
                findAndSetParentNode(parentNode.rightNode, newNode);
        }
        return true;
    }
/**
     * Utility method witch find parent by new node.
     *
     * @param parentNode Node
     * @param newNode    Node
     * @return
     */
Utility method witch find parent by new node.
@param parentNode Node
@param newNode    Node
@return
Utility method witch find parent by new node . @param parentNode Node @param newNode Node @return
private boolean findAndSetParentNode(Node parentNode, Node newNode) {
        if (newNode.value.compareTo(parentNode.value) == -1) {
            if (parentNode.leftNode == null)
                parentNode.leftNode = newNode;
            else
                findAndSetParentNode(parentNode.leftNode, newNode);
        } else {
            if (parentNode.rightNode == null)
                parentNode.rightNode = newNode;
            else
                findAndSetParentNode(parentNode.rightNode, newNode);
        }
        return true;
    }
private boolean findAndSetParentNode ( Node parentNode , Node newNode ) { if ( newNode . value . compareTo ( parentNode . value ) == - 1 ) { if ( parentNode . leftNode == null ) parentNode . leftNode = newNode ; else findAndSetParentNode ( parentNode . leftNode , newNode ) ; } else { if ( parentNode . rightNode == null ) parentNode . rightNode = newNode ; else findAndSetParentNode ( parentNode . rightNode , newNode ) ; } return true ; }
Utility method witch find parent by new node.
Utility method witch find parent by new node .