public Node getNextGreater(Node n)
{
Node t = null;
Node p = root;
t = root;
Node gp = null;
while (t != null && !n.Equals(t))
{
gp = p;
p = t;
if (n.CompareTo(t) < 0)
{
t = t.Left;
}
else
{
t = t.Right;
}
}
if (n.Data == this.getMax()) return null;
if (t.Right == null && t.Equals(p.Right)) return gp;
if (t.Right == null && t.Equals(p.Left)) return p;
if (t.Right.Left == null && t.Right.Right == null) return t.Right;
if (t.Right.Left != null) return t.Right.Left;
return null;
}
Sunday, December 27, 2009
Next Greater 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