Hey,
I have a small problem where i an not quite sure how to iterate through string data within a file and insert it into a tree list.
this is the code i currently worked out but i am stuck at the point where i need to add all the string data ( 1000 words) into the tree list.Code:#include <iostream> #include <stdlib.h> #include <algorithm> #include <fstream> #include "bintree.h" #include "binnode.h" using namespace std; void fillTree(bintree<string> &treeRoot); //void printTreeStats(const bintree<string> &treeRoot); int main(int argc, char *argv[]) { const int MAXDATA = 1000; bintree<string> treeRoot; /* if (argc != 2) { cout << "Syntax : family familyFile\n"; return 0; }*/ fillTree(treeRoot); // printTreeStats(treeRoot); treeRoot.rebalance(); // printTreeStats(treeRoot); return 0; } void fillTree(bintree<string> &treeRoot) { ifstream fin; string c; fin.open("dict.txt"); if (!fin) { cout << "Unable to read from file " << "\n"; exit(0); } while (!fin.eof()) { c = fin.get(); treeRoot.insert(c); } fin.close(); } /*void print(const bintree<string> &treeRoot) { }*/
Also just want to know can a tree have a lists within it ? because the program specification had something about lists and im not quite sure I understood it. Like lists which contain strings are nodes of a tree. (idk if that is even more confusin :P)
Any help is welcome. Thank you.



LinkBack URL
About LinkBacks



