"Left-most child next right sibling " traversal prob

I am trying to elaborate my prob here..
i used "Left-most child next right sibling" to simulate my Prefix Tree
for example:
1
2
3
4
5
6
        Node
Dlink/       \Blink

Blink:sibling
Dlink:parent



1
2
3
4
5
6
7
8
9
10
11
12
13
Prefix Tree
          A <- Root
     /        \
   AB          B
  /    \      /   \ 
 ABC   AC    BC     C

and in my structure it works like that:
        A <- Root
   /           \
  B              B
 /   \         /     \
C     C       C       C





so i can traverse each node by this order
A -> AB -> ABC -> AC -> B -> BC -> C
I used mark_Attributes array to mark every steps we visit,
so my source code is 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
void trie::List_Trie(void)
{
    for(int i=0;i<attributes;i++)mark_Attributes[i]=false;
    if(Root==NULL) cout<<"NULL"<<endl;
    else
    List_l(Root);
}

void trie::List_l(node * ptr)
{
    mark_Attributes[ptr->set]=true;
    for(int i=0;i<attributes;i++)
	{
		if(mark_Attributes[i])
		cout <<i<<" ";
	}
	cout<< "(" << ptr->count << ")" <<endl;
	
    if(ptr->Dlink!=NULL)
    {
        List_l(ptr->Dlink);
    }
	
    mark_Attributes[ptr->set]=false;

    if(ptr->Blink!=NULL)
    {
        mark_Attributes[ptr->set]=false;
        List_l(ptr->Blink);
    }
}


For now, i would like to modify partial changes to this way.
A -> B -> C -> BC -> AB -> AC -> ABC
to make sure we visit BC , we already visited B and C
(except for the length 1 items, cause length 1 item didn't have a subset except for NULL)
I've trying for a while, but it still a mess ,please help me!
Last edited on
Topic archived. No new replies allowed.