| | |
Binary Tree - Next Highest Value
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Nov 2008
Posts: 10
Reputation:
Solved Threads: 0
I have a binary tree
50
30 70
10 40 60 80
The below code is not giving the correct result for test cases 80, 83, 60, 11
50
30 70
10 40 60 80
The below code is not giving the correct result for test cases 80, 83, 60, 11
C# Syntax (Toggle Plain Text)
public partial class Default2 : System.Web.UI.Page { public class FindNextHighestNuber { public int search(int InputNumber) { int NextHighestNuber = ""; int NodeValue = this.RootNode.value; ActionOnNode(NodeValue, InputNumber); } public int ActionOnNode(int NodeValue, int InputNumber) { if (NodeValue <= InputNumber) { if (this.RightChild.value != "") { NodeValue = this.RightChild.value; ActionOnNode(NodeValue, InputNumber); } else { return this.Parent.value; } } else { if (this.LeftChild.value != "") { NodeValue = this.LeftChild.value; ActionOnNode(NodeValue, InputNumber); } else { return this.LeftChild.value; } } } } }
•
•
Join Date: Nov 2008
Posts: 10
Reputation:
Solved Threads: 0
We have a binary tree
50
30 70
10 40 60 80
The following code doesn't work for 80, 83 , 60, 40
50
30 70
10 40 60 80
The following code doesn't work for 80, 83 , 60, 40
C# Syntax (Toggle Plain Text)
public partial class Default2 : System.Web.UI.Page { public class FindNextHighestNuber { public int search(int InputNumber) { int NextHighestNuber = ""; int NodeValue = this.RootNode.value; ActionOnNode(NodeValue, InputNumber); } public int ActionOnNode(int NodeValue, int InputNumber) { if (NodeValue <= InputNumber) { if (this.RightChild.value != "") { NodeValue = this.RightChild.value; ActionOnNode(NodeValue, InputNumber); } else { return this.Parent.value; } } else { if (this.LeftChild.value != "") { NodeValue = this.LeftChild.value; ActionOnNode(NodeValue, InputNumber); } else { return this.LeftChild.value; } } } } }
![]() |
Similar Threads
- binary search trees (Computer Science)
Other Threads in the C# Forum
- Previous Thread: Theading problem
- Next Thread: how i can fetch the from datagrid
| Thread Tools | Search this Thread |
.net access algorithm animation array avltree bitmap box c# check checkbox client combobox control conversion csharp customactiondata database datagrid datagridview dataset date/time datetime datetimepicker degrees directrobot display dll draganddrop drawing encryption enum excel file filename files form format forms function gdi+ gtk hash image input install java keypress leak list math mouseclick mp3 mysql native networking operator outlook2003 packaging path photoshop picturebox pixelinversion pixelminversion post print process programming radians regex remoting richtextbox safari server sleep snooze socket sql statistics string table tables tcp text textbox thread time timer update usercontrol usercontrols validation visualstudio webbrowser webcam wfa wia winforms wpf xml





