tree with multiple nodes

Hey all!

I created 3 classes: tNode, dNode and myTree.

In the beginning of my code i create a vector<dNode*> with a fixed size and that vector never changes.

What my code needs to do is to implement some path planning and decide what is the shortest way from one node to another. The problem is that i don't need to do it once, but several times in several diferent ways.

My first approach was to implement a decision tree with classes myTree and tNode. This would create a tree with (hopefully) all possible choices from the vector<dNode>, and i could compute which branch is the best after. My first question is: is this the best way to compute all possible choices or should i try another approach?

Secondly, i successfully implemented the tree and it actually creates all possible ways. My problem here is that since it creates a tree that is REALLY huge, it takes a lot of time (around 10 or 15 min for the worst case scenario) and i need it to be as fast as possible ( less than 1 minute would be the best, but i could work with something between 1 and 2 minutes).

I figured that it might be because when i want to add a node to myTree i use "new tNode()" (thus creating millions of tNode elements in memory). The solution i thought for this was to forget about the class tNode and store in myTree a pointer to the actual dNode. This would be lighter in the memory ( i would be storing only addresses instead of tNode elements) and supposedly faster too. My problems here are:
is this a good solution? would it actually make the creation of the tree faster?
if it is, how can i implement this? i have to say that although i can manage pretty good (i think) in c++, my pointer knowledge goes as far as to pass variables by reference to functions and even then i need to check if i'm doing it right... ahah

oh! i also though about using multi-threading (although i have never done anything in that field... i only know the idea) and separate the tree. Instead of creating only one tree with all the info, create several at the same time. i also tried this and creating the smallest tree i can also takes like 5 minutes, it's better, but i still wanted to reach the less than 1 minute if possible...

many thanks to all in advance!

Topic archived. No new replies allowed.