Tries deletion in c++

Hi folks, I have been reading tries implementation in c++ and stuck in tries deletion part.
Here is the link to the article: http://www.geeksforgeeks.org/trie-delete/
I’m confused on this statement in recursive part :

return ( !leafNode(pNode) && isItFreeNode(pNode) );

Here is the code for deletion I have been reading on geeks for geeks.Pls, help me out in recursive part.

bool deleteHelper(trie_node_t *pNode, char key[], int level, int len)
{
    if( pNode )
    {
        // Base case
        if( level == len )
        {
            if( pNode->value )
            {
                // Unmark leaf node
                pNode->value = 0;
 
                // If empty, node to be deleted
                if( isItFreeNode(pNode) )
                {
                    return true;
                }
 
                return false;
            }
        }
        else // Recursive case
        {
            int index = INDEX(key[level]);
 
            if( deleteHelper(pNode->children[index], key, level+1, len) )
            {
                // last node marked, delete it
                FREE(pNode->children[index]);
 
                // recursively climb up, and delete eligible nodes
                return ( !leafNode(pNode) && isItFreeNode(pNode) );
            }
        }
    }
 
    return false;
}
1 Like