| | |
Binary Tree - Next Highest Value
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 138
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,162
Reputation:
Solved Threads: 138
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,162
Reputation:
Solved Threads: 138
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,162
Reputation:
Solved Threads: 138
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,162
Reputation:
Solved Threads: 138
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
Views: 1266 | Replies: 11
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access algorithm array barchart bitmap box buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees draganddrop drawing encryption enum event excel file files form format forms ftp function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






