0

after finishing while loop,when it wants to quit the recursive( node curr) method,it comes back again to the recursive call(recursive (nod)) in the for loop and it traps in several loops till an exception occurs saying that "index was out of the rang of the array" .
can anyone help please...

public void recursive(Node curr)
{

while ( sour <= source.Length - 2)

{
for (int i = 0; i < curr.ChildNumber; i++)
{
nod = (Node)curr.nextNode[i];
while (source[sour] != nod.CurrentNodeName)
{
continue;

}
sour = sour + 1;
Console.WriteLine(nod.CurrentNodeName);
recursive((Node)nod);

}
sour = sour + 1;
}


}
2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by f1 fan
0

You have all your logic in a big tangled mess.

I suggest you start by writing in pseudo code what you want to do and then code. You have while loops that do nothing, while loops inside for loops inside while loops and call the same method inside all those loops. A recipe for disaster.

You can simplify this greatly.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.