public Node getNextSmaller(Node r)
{
Node t = root;
Node gp = root;
Node p = root;
t = root;
while (t != null && !r.Equals(t))
{
gp = p;
p = t;
if (r.CompareTo(t) < 0)
{
t = t.Left;
}
else
{
t = t.Right;
}
}
if (t.Data == this.getMin()) return null;
if (t.Left == null && p.Data < t.Data) return p;
if (t.Left == null && p.Data > t.Data) return gp;
if (t.Left != null && t.Left.Right != null)
{
t = t.Left.Right;
while (t.Right != null)
{
t = t.Right;
}
return t;
}
if (t.Left != null && t.Left.Right == null) return t.Left;
return null;
}
Sunday, December 27, 2009
Next Smaller Node
Subscribe to:
Post Comments (Atom)
-
All WMI Class Names list : - Name ...
-
$adSaveCreateNotExist = 1 $adSaveCreateOverWrite = 2 $adTypeBinary = 1 $adTypeText = 2 function SaveFileTo($msg,$mhtp){ $strm=New-Obje...
-
url: https://www.youtube.com/watch?v=Tq4w5qfCjko&ab_channel=C%23Guy Entity Framework Core 3.0 and Rest API, how to, tutorial #dotnetc...
No comments:
Post a Comment