| | |
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 ado.net algorithm api array barchart bitmap box broadcast buttons c# check checkbox client combobox control conversion csharp custom database datagrid datagridview dataset datetime decryption degrees development drag draganddrop drawing encryption enum event excel file form format forms function gdi+ grantorrevokepermissionthroughc#.net httpwebrequest image index input install java label list listbox mandelbrot marshalbyrefobject math mouseclick mysql netcfsvcutil.exe numeric operator path photoshop php picturebox pixelinversion platform polynomial post programming properties radians regex remote remoting richtextbox server sleep socket sql statistics stream string study table teamsuite text textbox thread time timer update usb usercontrol validation visualstudio webbrowser windows winforms wpf wpfc# xml






