Hi,
I have a simple tree and I just want to print the parent id and the child ids using recursion. I have somthing like this.
2
/ \
3 4
/ \ / \
5 6 7 8
/\ /\ /\ /\
9 10 11 12 13 14 15 16
I want to traverse it like this
2 3 5 9 10 6 11 12 4 7 13 14 8 15 16.
I wrote simple recursion. the full program si provided at http://pastebin.ca/1354550. Just to illustrate the recrusion (If u happen to look at code dont messed up with the fill method, I am using this to simply my problem using in my project)
Code:
int order_display(long fid, long tid)
{
fot = FOST.find(fid);
if(fot != FOST.end())
{
int r = 0;
for(FOT.t = FOT.tids.begin();
FOT.t != FOT.tids.end();
FOT.t++)
{
fot1 = FOST1.find(*FOT.t);
if(fot1 != FOST1.end())
{
cout<<"tid "<<*FOT.t<<", creates family "<<FOT1<<endl;
//recursion
order_display(FOT1, *FOT.t);
}
else
{
cout<<"tid == "<<*FOT.t<<endl;
}
}
//return 1;
}
}
Can you please identify what is the problem. Coz I go till 2 3 5 8 9. But it does not go to the other family on the next to the lowest level. Any help will be appreciated.
i.