AVL Tree with strings? Memory overflow?
I found a way to do what I wanted, and have the same problem, marvelous.
The entire code is here: http://pastebin.com/wMfDtwfg for the int implementation
or here: http://pastebin.ca/1964677 for the string implementation.
My test is just a simple for loop that inserts a million int in ascending order. When I insert ten million the program breaks. One million int insertions uses up about a gig and a half of memory. But, I don't get any errors unless I do ten million inserts.
What I will be doing is inserting strings from a text file. Specifically a dictionary, and words starting with S. It's a pretty big list. I'm getting weird heights like 4868, that I don't get when I simply insert an int. Could the problem lie here?
Code:
ifstream inFile;
AVLTree dictionary;
inFile.open("dictS.txt");
string word;
string definition;
string dump;
while (!inFile.eof())
{
inFile >> dump;
if (dump.at(0) == '*')
{
if (word != "")
{
dictionary.insert(word, definition);
word = dump;
}
else
{
word = dump;
}
definition = "";
}
else
{
definition = definition + " " + dump;
}
}
inFile.close();
Any help would be appreciated.