Binary tree sort issues

Pages: 12
So i have this code here that reads in a file and then counts how many words are in it and then ouputs it
"You should list only words of length four or greater, and list a word only once with an annotation for the number of times it appears. For example:"
alpha
beta (3)
"Punctuation marks, spaces, and numerals are to be removed and not listed, all capitals should be lowercase."

SO far all i got it to do was to display the words in a list alphabetical order
i need help removing all punctuation from the text file and then to have it actually show the counted words.

Any help would be greatly appericated, Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
  #include<iostream>
#include<string>
#include<fstream>
#include<algorithm>
#include<iomanip> 

using namespace std;

struct Display
{
	string words;;
	int count;
};

struct Node
{
	Display value;
	Node* pLeft;
	Node* pRight;
};

Node* add(Node* tree, Display value);
Node* addNode(Node* tree, Node* toAdd);

bool treeContains(Node* tree, string word) ;
void displayAlphabetTree(Node* tree); 
void removeLastPunctuation(Node* tree);

int main()
{	
	Display value;
	string choiceStr;
	bool eofReached = false;

	value.count = 0;

	Node* tree = 0;

	string txtFile;

	
	ifstream myfile("speech.txt");
	
	if(!myfile)
	{
		cout << "Error, can't open file" << endl;
		exit(1);
	}
	else
	{		
		while(!myfile.eof()) 
		{
			myfile >> value.words;	
			eofReached = myfile.eof();

			if (treeContains(tree, value.words) == false)
			{				
				tree = add(tree, value);
			}
		}
	}
	{
		displayAlphabetTree(tree);
	}
	myfile.close();
}

Node* add(Node* tree, Display value)
{
        //tempPtr is a temporary pointer

	Node* tempPtr = new Node;
	tempPtr->value = value;
	tempPtr->pLeft  = 0;
	tempPtr->pRight = 0;
	return addNode(tree, tempPtr);
}

Node* addNode(Node* tree, Node* toAdd)
{
	if (tree == 0)
	{
		return toAdd;
	}
	else
	{
		if(toAdd->value.words < tree->value.words)
		{
			tree->pLeft = addNode(tree->pLeft, toAdd);
			return tree;
		}
		else if(toAdd->value.words == tree->value.words)
		{
			tree->value.count++;
			return tree;
		}
		else
		{
			tree->pRight = addNode(tree->pRight, toAdd);
			return tree;

		}
	}

}

bool treeContains(Node* tree, string word)  
{
	// If a word is in the binary
	// tree then true is returned.   
	// Vice versia, false is returned if not.

	if (tree == NULL) 
	{
        // Tree is empty, so it certainly doesn't contain item.
        return false;
    }
   else if (word == tree->value.words) 
   {
       //The word matches to one in the root node.
       return true;
    }
    else if (word < tree->value.words) 
	{
		// The word is less than the one in the root node
		// and must be sent to the left subtree.
		return treeContains(tree->pLeft, word);
    }
    else 
	{
		// The word is more than the one in the root node
		// and must be sent to the right subtree.
        return treeContains(tree->pRight, word);
     }
}

void displayAlphabetTree(Node* tree)
{	
    if(tree != 0)
	{		
		displayAlphabetTree(tree->pLeft);		
		displayAlphabetTree(tree->pRight);	
		cout<<tree->value.words<<"  "<<"["<<tree->value.count<<"]"<<endl;
	}
}

Last edited on
Is it mandatory to use binary trees for this assignment?

EDIT:
If you are allowed to avoid binary trees, then I suggest the following:

1. Read the words from the text sequentially ( while ( myfile >> word ) ).
2. For each word, apply conditioning.
- erase all non-alphabetical characters and convert all to lower case.
- If after conditioning, its length is less than 4 then discard it.
3. Form a unique map of <std::string, int> that will keep a count of number of times a particular word is encountered.
4. For each conditioned word, check whether it is contained in the map. If yes, then increment the count, else set the count to 1.

For outputting, just iterate through the map.
Last edited on
Hello,
We are required to use binary trees, i know how to do it using string but i have to use binary trees.
Well then instead of reading myfile >> value.words; first store it in a temporary string newWord, condition it as I described and then if its long enough, add it to the tree.

You are doing the rest already.
well i tried doingit like that but it either outputs the first word in the speech or the last word.
this just displays a [0] and nothing else

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include<iostream>
#include<string>
#include<fstream>
#include<algorithm>
#include<iomanip> 

using namespace std;

struct Display
{
	string words;;
	int count;
};

struct Node
{
	Display value;
	Node* pLeft;
	Node* pRight;
};

Node* add(Node* tree, Display value);
Node* addNode(Node* tree, Node* toAdd);

bool treeContains(Node* tree, string word) ;
void displayAlphabetTree(Node* tree); 
void removeLastPunctuation(string&);

int main()
{	
	string newword;
	Display value;
	bool eofReached = false;

	value.count = 0;

	Node* tree = 0;
	
	ifstream myfile("speech.txt");
	
	if(!myfile)
	{
		cout << "Error, can't open file" << endl;
		exit(1);
	}
	else
	{		
		while(!myfile.eof()) 
		{
			myfile >> newword;	
			removeLastPunctuation(newword);
			newword = value.words;
			
			eofReached = myfile.eof();

			if (treeContains(tree, value.words) == false)
			{				
				tree = add(tree, value);
			}
		}
	}
	displayAlphabetTree(tree);
	myfile.close();
}

Node* add(Node* tree, Display value)
{
        //tempPtr is a temporary pointer
	
	Node* tempPtr = new Node;
	tempPtr->value = value;
	tempPtr->pLeft  = 0;
	tempPtr->pRight = 0;
	return addNode(tree, tempPtr);
}

Node* addNode(Node* tree, Node* toAdd)
{
	
	if (tree == 0)
	{
		return toAdd;
	}
	else
	{
		if(toAdd->value.words < tree->value.words)
		{
			tree->pLeft = addNode(tree->pLeft, toAdd);
			return tree;
		}
		else if(toAdd->value.words == tree->value.words)
		{
			tree->value.count++;
			return tree;
		}
		else
		{
			tree->pRight = addNode(tree->pRight, toAdd);
			return tree;

		}
	}

}

bool treeContains(Node* tree, string word)  
{
	// If a word is in the binary
	// tree then true is returned.   
	// Vice versia, false is returned if not.

	if (tree == NULL) 
	{
        // Tree is empty, so it certainly doesn't contain item.
        return false;
    }
   else if (word == tree->value.words) 
   {
       //The word matches to one in the root node.
       return true;
    }
    else if (word < tree->value.words) 
	{
		// The word is less than the one in the root node
		// and must be sent to the left subtree.
		return treeContains(tree->pLeft, word);
    }
    else 
	{
		// The word is more than the one in the root node
		// and must be sent to the right subtree.
        return treeContains(tree->pRight, word);
     }
}

void displayAlphabetTree(Node* tree)
{	
    if(tree != 0)
	{		
		displayAlphabetTree(tree->pLeft);		
		displayAlphabetTree(tree->pRight);	
		cout<<tree->value.words<<"  "<<"["<<tree->value.count<<"]"<<endl;
	}
}

void removeLastPunctuation(string& newword)
{
    if (newword.length() > 1) {
        char chLast = char(newword[newword.length()-1]);
        if (ispunct(chLast)) {
            newword.erase(newword.length()-1, 1);
            removeLastPunctuation(newword);
        }
    }
}
Line 53 52 newword = value.words; Don't you have that backwards?


Edit:: Wrong line #
Last edited on
haha silly mistake, cant believe i didnt see that,

So for the lower case i would do the exact same process as i did for the removal of punctuation right?
Also how do i make it so that the Binary Tree only outputs words of 4 letters or greater.
So for the lower case i would do the exact same process as i did for the removal of punctuation right?

Unless you have words that are all caps.


Also how do i make it so that the Binary Tree only outputs words of 4 letters or greater.

Check the size of the string that you read in.
Okay so i got the letters to be in lower case but its not outputting in alphabet order. it outputs it weird like:

would
worldwide
world
The first word that you read in is the root node and never changes. You don't handle the case where the next word is less than the root node.
So there is an issue in my addNode function or treeContains function?
In your addNode function you need to check to see if the new word is less than the current root node and if so swap them. Then continue down your tree with the old root node. Also, since you have a return in each of your if statements you don't need the else(s).

Try something like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Node* addNode(Node* tree, Node* toAdd)
{
    if (tree == 0)    {
        return toAdd;
    }
    if(toAdd->value.words.compare(tree->value.words) < 0){  // make the new node the 
        Node *tmp = tree;                                   // root node if true   
        tree = toAdd;
        toAdd = tmp;
    }
    if(toAdd->value.words < tree->value.words){
            tree->pLeft = addNode(tree->pLeft, toAdd);
            return tree;
    }
    if(toAdd->value.words == tree->value.words){
            tree->value.count++;
            return tree;
    }
    tree->pRight = addNode(tree->pRight, toAdd);
    return tree;
}
Ah i see. This is my first time programing with binary trees so im not so good at it. But thank you for the help. Will post if i run into any more issues.
Okay so everything seems to work now the only issue left is that its not increasing the count of the words that appear. it just stays at 1 and doesn't increment at all

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#include<iostream>
#include<string>
#include<fstream>
#include<algorithm>
#include<iomanip> 

using namespace std;

struct Display
{
	string words;;
	int count;
};

struct Node
{
	Display value;
	Node* pLeft;
	Node* pRight;
};

Node* add(Node* tree, Display value);
Node* addNode(Node* tree, Node* toAdd);
bool treeContains(Node* tree, string word) ;
void displayAlphabetTree(Node* tree); 
void removeLastPunctuation(string&);
void toLower(string &);

int main()
{	
	string newword;
	Display value;
	

	value.count = 1;

	Node* tree = 0;
	
	ifstream myfile("speech.txt");
	
	if(!myfile)
	{
		cout << "Error, can't open file" << endl;
		exit(1);
	}
	else
	{		
		while(!myfile.eof()) 
		{
			myfile >> newword;
			toLower(newword);	
			removeLastPunctuation(newword);
			value.words = newword;

			if (treeContains(tree, value.words) == false)
			{				
				tree = add(tree, value);
			}
		}
	}
	displayAlphabetTree(tree);
	myfile.close();
}

Node* add(Node* tree, Display value)
{
        //tempPtr is a temporary pointer
	
	Node* tempPtr = new Node;
	tempPtr->value = value;
	tempPtr->pLeft  = 0;
	tempPtr->pRight = 0;
	return addNode(tree, tempPtr);
}

Node* addNode(Node* tree, Node* toAdd)
{
    if (tree == 0)    {
        return toAdd;
    }
    if(toAdd->value.words.compare(tree->value.words) > 0)
	{  
        Node *tmp = tree;                                     
        tree = toAdd;
        toAdd = tmp;
    }
    if(toAdd->value.words < tree->value.words){
            tree->pLeft = addNode(tree->pLeft, toAdd);
            return tree;
    }
    if(toAdd->value.words == tree->value.words){
            tree->value.count++;
            return tree;
    }
    tree->pRight = addNode(tree->pRight, toAdd);
    return tree;
}

bool treeContains(Node* tree, string word)  
{
    if (tree == NULL) 
    {
        // Tree is empty, so it certainly doesn't contain item.
        return false;
    }
    else if (word == tree->value.words) 
    {
       //The word matches to one in the root node.
       return true;
    }
    else if (word < tree->value.words) 
	{
		// The word is less than the one in the root node
		// and must be sent to the left subtree.
		return treeContains(tree->pLeft, word);
    }
    else 
	{
		// The word is more than the one in the root node
		// and must be sent to the right subtree.
        return treeContains(tree->pRight, word);
     }
}

void displayAlphabetTree(Node* tree)
{	
    if(tree != 0)
	{		
		displayAlphabetTree(tree->pLeft);		
		displayAlphabetTree(tree->pRight);	
		cout<<tree->value.words<<"  "<<"("<<tree->value.count<<")"<<endl;
	}
}

void removeLastPunctuation(string& newword)
{
    if (newword.length() > 1) 
	{
        char chLast = char(newword[newword.length()-1]);
        if (ispunct(chLast)) 
		{
			newword.erase(newword.length()-1, 1);
            removeLastPunctuation(newword);
        }
		if (newword.length() > 1) 
		{
			char chFirst = char(newword[0]);
			if (ispunct(chFirst))
			{
				newword.erase(0, 1);
				removeLastPunctuation(newword);
			}
		}
    }
}

void toLower(string& newword)
{
	char c;
    for (int i=0; i<newword.length(); i++) 
	{
		c = newword[i];
        newword[i] = tolower(c);
    }
}



@ninthred - I need to apologize. The only thing that I told you above that is correct is that you can do away with the else statements. Your addNode code works perfectly.

The problem is in displayAlphaTree(). You just need to move the cout statement between the two recursive calls:
1
2
3
4
5
6
7
8
9
10
void displayAlphabetTree(Node* tree)
{
    if(tree != 0)
    {
        displayAlphabetTree(tree->pLeft);
        cout<<tree->value.words<<"  "<<"["<<tree->value.count<<"]"<<endl;
        displayAlphabetTree(tree->pRight);
//        cout<<tree->value.words<<"  "<<"["<<tree->value.count<<"]"<<endl;
    }
}


addNode() can revert to your original code or you can eliminate the else statements:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Node* addNode(Node* tree, Node* toAdd)
{
    if (tree == 0)    {
        return toAdd;
    }
    if(toAdd->value.words < tree->value.words){
            tree->pLeft = addNode(tree->pLeft, toAdd);
            return tree;
    }
    if(toAdd->value.words == tree->value.words){
            tree->value.count++;
            return tree;
    }
    tree->pRight = addNode(tree->pRight, toAdd);
    return tree;
}


As for the word count I think you need to increment value.count in treecontains() if the word is already in the tree.

Again, I apologize for erroneous "help".
the method you showed me also worked, but no need to apologize, some help is better than no help ^^

so i was converting my code to have a class but its giving me errors saying
error: 'Node' does not name a type
on lines 55 and 64 in my tree.cpp file.

i tried fixing it but no luck on how to do it.

main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <tree.h>
#include <tree.cpp>
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
#include <iomanip> 

using namespace std;

int main()
{	
	tree mytree;
	mytree.run();
}


tree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef TREE_H
#define TREE_H
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
#include <iomanip> 

using namespace std;

class tree
{
public:

struct Display
{
	string words;;
	int count;
};

struct Node
{
	Display value;
	Node* pLeft;
	Node* pRight;
};


tree();
	Node* add(Node* tree, Display value);
	Node* addNode(Node* tree, Node* toAdd);
	bool treeContains(Node* tree, string word) ;
	void displayAlphabetTree(Node* tree); 
	void removeLastPunctuation(string&);
	void run();
	void toLower(string &);
~tree();
};

#endif // TREE_H


tree.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include "tree.h"
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
#include <iomanip> 

using namespace std;

tree::tree()
{
	string newword;
	Display value;
	
	value.count = 0;
	Node* tree = 0;
}

void tree::run()
{
	
	string newword;
	Display value;
	
	value.count = 1;

	Node* tree = 0;
	
	ifstream myfile("speech.txt");
	
	if(!myfile)
	{
		cout << "Error, can't open file" << endl;
		exit(1);
	}
	else
	{		
		while(!myfile.eof()) 
		{
			myfile >> newword;
			toLower(newword);	
			removeLastPunctuation(newword);
			value.words = newword;

			if (treeContains(tree, value.words) == false)
			{				
				tree = add(tree, value);
			}
		}
	}
	displayAlphabetTree(tree);
	myfile.close();
}

Node* add(Node* tree, Display value)
{
	Node* tempPtr = new Node;
	tempPtr->value = value;
	tempPtr->pLeft  = 0;
	tempPtr->pRight = 0;
	return addNode(tree, tempPtr);
}

Node* addNode(Node* tree, Node* toAdd)
{
    if (tree == 0)    {
        return toAdd;
    }
    if(toAdd->value.words < tree->value.words){
            tree->pLeft = addNode(tree->pLeft, toAdd);
            return tree;
    }
    if(toAdd->value.words == tree->value.words){
            //tree->value.count++;
            return tree;
    }
    tree->pRight = addNode(tree->pRight, toAdd);
    return tree;
}

bool tree::treeContains(Node* tree, string word)  
{
	if (tree == NULL) 
	{
        return false;
    }
   else if (word == tree->value.words) 
   {
	   tree->value.count++;
       return true;
    }
    else if (word < tree->value.words) 
	{
		return treeContains(tree->pLeft, word);
    }
    else 
	{
        return treeContains(tree->pRight, word);
     }
}

void tree::displayAlphabetTree(Node* tree)
{	
    if(tree != 0)
	{		
		displayAlphabetTree(tree->pLeft);
        cout<<tree->value.words<<"  "<<"("<<tree->value.count<<")"<<endl;	
		displayAlphabetTree(tree->pRight);	
		
	}
}

void tree::removeLastPunctuation(string& newword)
{
    if (newword.length() > 1) 
	{
        char chLast = char(newword[newword.length()-1]);
        if (ispunct(chLast)) 
		{
			newword.erase(newword.length()-1, 1);
            removeLastPunctuation(newword);
        }
		if (newword.length() > 1) 
		{
			char chFirst = char(newword[0]);
			if (ispunct(chFirst))
			{
				newword.erase(0, 1);
				removeLastPunctuation(newword);
			}
		}
    }
}

void tree::toLower(string& newword)
{
	char c;
    for (int i = 0; i < newword.length(); i++) 
	{
		c = newword[i];
        newword[i] = tolower(c);
    }
}

tree::~tree()
{
}

Last edited on
You need the class name and the scope resolution operator on those functions. Also since you
have Node inside your class, I think you will have to do the same with the return value.

e.g. the signature of add will need to be: tree::Node* tree::add(Node* tree, Display value)
when i do it like thatit gives me 11 errors saying
tree.cpp:10: first defined here
tree.cpp:65: first defined here

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include "tree.h"
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
#include <iomanip> 

using namespace std;

tree::tree()
{
	string newword;
	Display value;
	
	value.count = 0;
	Node* tree = 0;
}

void tree::run()
{
	
	string newword;
	Display value;
	
	value.count = 1;

	Node* tree = 0;
	
	ifstream myfile("speech.txt");
	
	if(!myfile)
	{
		cout << "Error, can't open file" << endl;
		exit(1);
	}
	else
	{		
		while(!myfile.eof()) 
		{
			myfile >> newword;
			toLower(newword);	
			removeLastPunctuation(newword);
			value.words = newword;

			if (treeContains(tree, value.words) == false)
			{				
				tree = add(tree, value);
			}
		}
	}
	displayAlphabetTree(tree);
	myfile.close();
}

tree::Node* tree::add(Node* tree, Display value)
{
	Node* tempPtr = new Node;
	tempPtr->value = value;
	tempPtr->pLeft  = 0;
	tempPtr->pRight = 0;
	return addNode(tree, tempPtr);
}

tree::Node* tree::addNode(Node* tree, Node* toAdd)
{
    if (tree == 0)    {
        return toAdd;
    }
    if(toAdd->value.words < tree->value.words){
            tree->pLeft = addNode(tree->pLeft, toAdd);
            return tree;
    }
    if(toAdd->value.words == tree->value.words){
            //tree->value.count++;
            return tree;
    }
    tree->pRight = addNode(tree->pRight, toAdd);
    return tree;
}

bool tree::treeContains(Node* tree, string word)  
{
	if (tree == NULL) 
	{
        return false;
    }
   else if (word == tree->value.words) 
   {
	   tree->value.count++;
       return true;
    }
    else if (word < tree->value.words) 
	{
		return treeContains(tree->pLeft, word);
    }
    else 
	{
        return treeContains(tree->pRight, word);
     }
}

void tree::displayAlphabetTree(Node* tree)
{	
    if(tree != 0)
	{		
		displayAlphabetTree(tree->pLeft);
        cout<<tree->value.words<<"  "<<"("<<tree->value.count<<")"<<endl;	
		displayAlphabetTree(tree->pRight);	
		
	}
}

void tree::removeLastPunctuation(string& newword)
{
    if (newword.length() > 1) 
	{
        char chLast = char(newword[newword.length()-1]);
        if (ispunct(chLast)) 
		{
			newword.erase(newword.length()-1, 1);
            removeLastPunctuation(newword);
        }
		if (newword.length() > 1) 
		{
			char chFirst = char(newword[0]);
			if (ispunct(chFirst))
			{
				newword.erase(0, 1);
				removeLastPunctuation(newword);
			}
		}
    }
}

void tree::toLower(string& newword)
{
	char c;
    for (int i = 0; i < newword.length(); i++) 
	{
		c = newword[i];
        newword[i] = tolower(c);
    }
}

tree::~tree()
{
}

Pages: 12