Daily Archives: September 14, 2012

reverse word in a string

    void reverseWordinString( char *s ){    char *p1, *p2;    p1 =  p2 = s;     while( *p2 != ” )    {        p2++;    }    // you are one step ahead    p2–;     // invert the whole string    reverse( p1, p2 … Continue reading

Posted in Uncategorized | Leave a comment

find tre path

public void findAllPath( Node root, int sum, LinkedList<int> link ){    LinkedList<int> linkTemp = new LinkedList<int>();    copyLink( linkTemp, link );     if( root == NULL )    {        return ;    }    if( sum < root.data )    {        return ;    }    link.add( root.data … Continue reading

Posted in Uncategorized | Leave a comment

verify if a sequences is the post order traversal of a tree

public boolean postOrderCheck( int sequences[], int length )    {        if( sequences == null || sequences.length == 0 )        {            return false;        }         // boundary-1 would be the index of left child        // length – 2 would be the root … Continue reading

Posted in Uncategorized | Leave a comment