what mistake in my insert function of trie implementation
<pre><code>#include&lt;iostream&gt;

using namespace std;

class trie
{
    public:
        struct node
        {
            node* children[26];
            int value;
            char data;
            node()
            {
                value = 0;

                for ( int i = 0; i &lt; 26; i++ )
                {
                    children[i] = NULL;
                }
            }   
        };

        node* root;

        trie()
        {
            root=NULL;
        }

        void intialize( node *&amp; tree )
        {
            if ( tree == NULL )
            {
                tree = new node;
                tree-&gt;value=9999;
                cout &lt;&lt; "root value sucessfully intialized with NULL" &lt;&lt; endl;
            }
            else
            {
                cout &lt;&lt; "it is already filled " &lt;&lt; endl;
            }
        }

        void insert1()
        {
            //intialize( root );
            insert( root );
        }

        void insert( node *&amp; root1 )
        {
            int count = 0;
            cout &lt;&lt; "enter the string" &lt;&lt; endl;
            string a;
            cin &gt;&gt; a;
            int len = a.length();
            int index;
            count++;
            for ( int i = 0; i &lt; len; i++ )
            {
                index = a[i] - 'a';
                cout &lt;&lt; index &lt;&lt; endl;
                if ( ! root1-&gt;children[index] )
                {
                    //cout &lt;&lt; "not entering" &lt;&lt; endl;
                    node *p;
                    p = new node;
                    p-&gt;data = index + 'a';
                    root1-&gt;children[index] = p;
                }
                root1 = root1-&gt;children[index];
            }
            //int l = 0;
            //cout &lt;&lt; "the value of g " &lt;&lt; g &lt;&lt; endl;
            root1-&gt;value = count;
        }

        void search1()
        {
            search( root );
        }

        void search( node *&amp; root1 )
        {
            string a;
            cout &lt;&lt; "enter the string you want to search" &lt;&lt; endl;
            cin &gt;&gt; a;
            int index;
            int len = a.length();
            for ( int i = 0; i &lt; len; i++ )
            {
                index = a[i] - 'a';
                cout &lt;&lt; index &lt;&lt; endl;
                cout &lt;&lt; "entered" &lt;&lt; endl;
                //root = root-&gt;children[index];
                if ( ! root-&gt;children[index] )
                {
                    cout &lt;&lt; "the string is not present" &lt;&lt; endl;
                    break;
                }
                cout &lt;&lt; "the value of the root is " &lt;&lt; root-&gt;data &lt;&lt; endl;
                root = root-&gt;children[index];
            }
            if ( root != NULL &amp;&amp; root-&gt;value )
            {
                cout &lt;&lt; "string is present" &lt;&lt; endl;
            }
        }
};

int main()
{
    trie b;
    int a;
    int n,x;
    b.intialize();
    while ( 1 )
    {
        cout &lt;&lt; "\n1 insert \n2 search";
        cout &lt;&lt; endl;
        cin &gt;&gt; a;
        switch ( a )
        {
            case 1:
                b.insert1();
                break;
            case 2:
                b.search1();
                break;
        }   
    }
}
</code></pre>

<p>Here is my implementation of trie. I am not able to figure what is wrong in my insert function. The root of tree is not updating here. For example, when I enter the input "usa", the tree gets created. But when I search for "usa" then it is showing "the string is not present". I am not able to figure out what is wrong in my code.</p>
