| | |
Binary Tree - Next Highest Value
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2008
Posts: 1,160
Reputation:
Solved Threads: 137
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,160
Reputation:
Solved Threads: 137
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,160
Reputation:
Solved Threads: 137
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,160
Reputation:
Solved Threads: 137
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,160
Reputation:
Solved Threads: 137
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 array backup barchart bitmap box broadcast buttons c# check checkbox client clock combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees developer development draganddrop drawing dynamiccreation encryption enum excel file form format forms function gdi+ hospitalmanagementsystems httpwebrequest image index input install interface java label list listbox mandelbrot math microsystems mouseclick mysql operator password path photoshop picturebox pixelinversion post priviallages. programming property radians regex remoting richtextbox running... serialization server sleep soap socket sql sqlserver stack statistics stream string table temperature text textbox thread time timer update usercontrol validation visualstudio webbrowser windows windowsformsapplication winforms wpf write xml






