Binary Tree - Next Highest Value
Please support our C# advertiser: DiscountASP.NET – 3 Months Free on C# Web Hosting
![]() |
•
•
Posts: 1,157
Reputation:
Solved Threads: 133
show us your code and we can help you out
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Posts: 10
Reputation:
Solved Threads: 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
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
•
•
Posts: 1,157
Reputation:
Solved Threads: 133
please put the code in code tags
do you have any of this done yourself in c# yet?
do you have any of this done yourself in c# yet?
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Posts: 10
Reputation:
Solved Threads: 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
Last edited by mapidea : Nov 18th, 2008 at 9:19 am.
•
•
Posts: 1,157
Reputation:
Solved Threads: 133
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
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
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Posts: 1,157
Reputation:
Solved Threads: 133
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.co...t-overview.php
here's a link that will give you a java version
MAKE AN EFFORT
http://simpleprogrammingtutorials.co...t-overview.php
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Posts: 10
Reputation:
Solved Threads: 0
How will you write
in C#
if self.rightChild:
succ = self.rightChild.findMin()in C#
•
•
Posts: 1,157
Reputation:
Solved Threads: 133
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
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
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
![]() |
Similar Threads
Other Threads in the C# Forum
- binary search trees (Computer Science)
Other Threads in the C# Forum
- Previous Thread: Theading problem
- Next Thread: how i can fetch the from datagrid
•
•
•
•
Views: 984 | Replies: 11 | Currently Viewing: 1 (0 members and 1 guests)






Linear Mode