recusive method problem

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2007
Posts: 7
Reputation: paeez is an unknown quantity at this point 
Solved Threads: 0
paeez paeez is offline Offline
Newbie Poster

recusive method problem

 
0
  #1
Jul 8th, 2007
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...
publicvoid 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;
}


}
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 275
Reputation: f1 fan is an unknown quantity at this point 
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

Re: recusive method problem

 
0
  #2
Jul 10th, 2007
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC