Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Espanol
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Espanol section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 27th, 2005, 05:53 AM
sangi
Guest
 
Posts: n/a
Default Stackoverflow error in recursive method (URGENT...

Hi all,

My code has the problem of stackoverflow when executing a recursive loop

my loop is as follows
     initially curr is null and node is getting values like 5,7,4,3,2,6.
i must store the values returned from recursion procedure in a tree named as next.
after inserting the nodes the recursion method must return the starting root .

initially root =null;

Call by:
---------------
BinaryTree next=new BinaryTree();
next.root=next.Recursive(n,next.root);
                    

Function:
-----------

     private BinaryNode Recursive(BinaryNode node,BinaryNode curr)
     {
         if(curr == null )
         {
         curr = node;
         }
         else
         {
             if ((node.key).compareTo(curr.key )<0)
             {
             if(curr.leftChild==null)
             {
             curr.leftChild=node;
             return curr;
             }
             else
             curr.leftChild=Recursive(node, curr.leftChild);
                            
             }
             else if ((node.key).compareTo(curr.key )>0)
             {
             if(curr.rightChild==null)
             {
                 curr.rightChild=node;
                 return curr;
                }
                else
                 curr.rightChild=Recursive(node, curr.rightChild);
                }
                            
             }
                        
             return curr;
         }




I thought problem was solved by increasing the internal stack size.but it still exists.....
please suggest some way for this recursion problem...
thanks in advance...





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call DLL Method in Javascritp? URGENT!!!!!! prabhakar123 Javascript 26 November 28th, 2011 07:06 AM
Urgent Help Needed : InvalidateControl Method vikasbhandari2 .NET Framework 3.5 0 June 11th, 2008 09:38 AM
error in Recursive version of glob method PHP Databases 1 July 27th, 2005 08:47 PM
CreateInstance method problem(urgent).. Srikanth_nd C# 0 June 16th, 2005 01:16 AM
getrows method-urgent????? mikedeepak Classic ASP Databases 6 September 1st, 2004 03:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.