I’ve created a node class and a tree class. From main, I call suffixTree t = new suffixTree(string); It is on a while loop so it will always be variable t.
The problem is, I want to read an input file and create a new tree for each string. Apparently, it won’t create a new instance.
The variable “t” is the same in each interaction but it should be a new instance everytime it creates it. The tree constructor, has a Node root = new Node();
It is a copied code, the only thing I did was to read from input and traverse the tree.
The problem is, if I type mississippi$ then acacdcacd$ it adds to the same tree and give a wrong result as I traverse it.
Thanks in advance
You are creating new instances but you are discarding them right after creation because they are not stored anywhere and as such they are unreachable and marked as ready for garbage collection.
have a look at the following: