Not Yet Answered # Binary Tree - Next Highest Value

Discussion Starter mapidea Discussion Starter mapidea dickersonka 104 dickersonka 104 Discussion Starter mapidea dickersonka 104 Discussion Starter mapidea Discussion Starter mapidea Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...

0

What will be the C# version of the below code.

int findSuccessor(self):

succ = None

if self.rightChild:

succ = self.rightChild.findMin()

else:

if self.parent.leftChild == self:

succ = self.parent

else:

self.parent.rightChild = None

succ = self.parent.findSuccessor()

self.parent.rightChild = self

return succ

int findMin(self):

n = self

while n.leftChild:

n = n.leftChild

print 'found min, key = ', n.key

return n

0

I have not done this in C#.

```
int findSuccessor(self):
succ = None
if self.rightChild:
succ = self.rightChild.findMin()
else:
if self.parent.leftChild == self:
succ = self.parent
else:
self.parent.rightChild = None
succ = self.parent.findSuccessor()
self.parent.rightChild = self
return succ
int findMin(self):
n = self
while n.leftChild:
n = n.leftChild
print 'found min, key = ', n.key
return n
```

0

then make an effort, and we will make an effort

if you are having trouble with a specific piece, rather than just though whole thing then let us know, we won't do the work for you

0

did you do it in python or is that some else's?

here's a link that will give you a java version

MAKE AN EFFORT

http://simpleprogrammingtutorials.com/tutorials/bst-overview.php

0

How will you write

```
if self.rightChild:
succ = self.rightChild.findMin()
```

in C#

0

in c# you have classes, think of it this way

you have a node, and a node on the left and right

each node is connected to another node (rightChild) and (leftChild)

you can't just translate this code to c#, you need to think about what structure you need first

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

```
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;
}
}
}
}
}
```

0

We have a binary tree

50

30 70

10 40 60 80

The following code doesn't work for 80, 83 , 60, 40

```
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;
}
}
}
}
}
```

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

```
public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}
```

the function that I created to find the ...