recursion - Java recursive binary tree -


Welcome! I have a recursive public static method, which is a tree node (a basic binary tree, not actually a search tree) and takes an integer parameter if all the values ​​in the paste are less than the integer. So, I will use a public square TN {public entrant value; Public Tien left, right; Public Tien (Int V, TN L, TN R) {value = v; Left = l; Therefore, my method will look like this:

  Public stable boolean low (TnS, int to find) {if (S == empty) back Is correct; And (if (S.Viewell and Lieutenant; = Towfind) returns the lower (S. left, tofind) and amp; less (S. Right, Toofid); // Right here I return the truth? Or do I remember anyhow I have to make a recursive false return again;}  

I was thinking that it was right or did I forget something ??? do I have to return true and false ??

  short return (s, tofind);  

Should be:

short return (S.B. I, dofind) & amp; amp; amp; amp; amp; amp; amp; amp; short (as well, tofid);

I do not know why the function is static.

As told earlier You must be the first part:

  If (S == blank) is back to true;  

(Edit: This will help you get a true result When all the nodes will complete the situation. You have a == that should be a & lt; edit: Okay, you have too many problems with those problems I Areas mentioned you need to logically crossing need to step through your code

you your tree, you'll need to call your function on their children nodes. After this, you have to return the truth as your default result. In this way, when you reach a higher number than anything else, then you can return any child without any kind of falsehood immediately. I hope I have helped you enough with the logic for you, so that you can get it through the rest.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -