| | |
Binary Tree - Next Highest Value
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Aug 2008
Posts: 1,158
Reputation:
Solved Threads: 136
show us your code and we can help you out
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Join Date: Nov 2008
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
•
•
Join Date: Aug 2008
Posts: 1,158
Reputation:
Solved Threads: 136
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
•
•
Join Date: Nov 2008
Posts: 10
Reputation:
Solved Threads: 0
I have not done this in C#.
C# Syntax (Toggle Plain Text)
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 10:19 am.
•
•
Join Date: Aug 2008
Posts: 1,158
Reputation:
Solved Threads: 136
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
•
•
Join Date: Aug 2008
Posts: 1,158
Reputation:
Solved Threads: 136
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
•
•
Join Date: Nov 2008
Posts: 10
Reputation:
Solved Threads: 0
How will you write
in C#
C# Syntax (Toggle Plain Text)
if self.rightChild: succ = self.rightChild.findMin()
in C#
•
•
Join Date: Aug 2008
Posts: 1,158
Reputation:
Solved Threads: 136
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
- 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 app application array bitmap box c# check checkbox client color combo combobox concurrency control conversion csharp custom cyclethruopenforms data database datagrid datagridview dataset datatable date/time datetime degrees dll draganddrop drawing enabled encryption enum excel file filename finalyearproject foreach form format forms function gdi+ getoutlookcontactusinfcsvfile globalization gtk image input install installer java keypress label list localization math microsoftc#visualexpress mono mouseclick mysql operator panel path photoshop picturebox pixelinversion post programming radians regex remoting richtextbox save server sleep socket sql sql-server statistics string table text textbox thread time timer timespan update usercontrol users validate validation visualstudio webbrowser winforms wpf xml






