Try a search on google for
"tree traversal" frequency "discrete math"
One way you could use the strcture described and start at the root of the tree.
I would add a function called
addWord(const string & newword, int linenumber);
In this function you would start at the root of the tree
you need to check for 3 conditions, either
if newword==treenode.word, then num_occurences+=1; lines.PushBack(linenumber); return;
if newword<treenode.word, then traverse to the left node
if newword>treenode.word, then traverse to the right node
You would continue checking and traversing until you either find the word already in the tree OR
If you get to a "leaf"(a leaf is a term used to describe a node in a tree that had no left or right subtrees, in other words the pointers left and right are null) and don't find the word in the tree, then that means you need to add a new node for that word. You would do a lessthan greaterthan check against the current node to see if you need to add the new node to the right or left.
Once you have processed all the words in your file, then it shouldn't be a hard task to output all the data in your tree one node at a time.
You need to read up on tree traversal.
If you aren't familier with linked list, then it is important you understand that concept first and how to implement them. This will give you the skills you need to deal with pointers and nodes in a tree.
Good luck!