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)
-
Objects are complex data type Const myObj = {}; console.log(myObj); const person = { firstName : ‘S’, lastName: ‘Man’, Age: 4 } person...
-
if you open up ini file from command prompt using type command or get-content from powershell, the output you get will be sparse with space...
-
$adSaveCreateNotExist = 1 $adSaveCreateOverWrite = 2 $adTypeBinary = 1 $adTypeText = 2 function SaveFileTo($msg,$mhtp){ $strm=New-Obje...
No comments:
Post a Comment