BST, anyone see whats wrong?

Anyone know whats wrong with my code?
Wanting to keep a frequency count on each word.  Its not incrementing right or frequency is not initialized right or something.

Any ideas?

Code here: <dead link removed by CetusMOD>
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You have a frequency variable for each Node, yet you initialize frequency = 0 in your Tree constructor and did not get a compile error? That's where the error lies.
Also, in your InsertItem, I don't know what the purpose of setting current = t is, but you seem to want to point it to the newly created Node. If that's the case, then your line current = t; should be in the same else loop with your allocation.
>>else {
>>   t = new TreeNode(Item,0,0);
>>   current = t;
and not outside of it. Otherwise your pointer current will be misplaced since there possibly will me many recursive calls before it waiting to finish up.
In your findNode, using return would be a safer habit than break.
>>if (current->data == searchItem) {
>>        break; // found match, store in BST current ptr
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

killer455Author Commented:
So frequency should not be initialized to anything?
The best logic is: your frequency variable belongs to class TreeNode, thus it should be initialized by that class itself. So allow your TreeNode constructor to do frequency = 0 for you. Remember if you have n Nodes that's n frequency variables for you.
   TreeNode(T newT, TreeNode *l, TreeNode *r)
      data = newT;
      left = l;
      right = r;
      frequency = 0;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
killer455Author Commented:
How would i start frequency at 1?
killer455Author Commented:
oh ok nm
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.