Here is the Code:
class Program
{
static void Main(string[] args)
{
// This Solution is written by me and is not completely tested. Please comment if you found any alternative solutions or any enhancement to my solution.
BSTnode n = new BSTnode(5);
n.add(2);
n.add(7);
n.add(3);
n.add(1);
n.add(6);
n.add(8);
n.add(9);
Console.WriteLine("---------------");
printBottom(n);
}
public static void printBottom(BSTnode n)
{
if (n.LeftNode == null && n.rightNode == null)
{
Console.Write(n.data + " ");
}
else
{
if (n.LeftNode != null)
{
printBottom(n.LeftNode);
}
if (n.rightNode != null)
{
printBottom(n.rightNode);
}
}
}
}
Popular Posts
-
Here is the code: // => Brute Force Solution: O(m* n) static long arrayManipulation(int n, int[][] queries) { ...
-
Whatever it is one fine day everyone on this planet who are born have to die for sure. When you are close ones are with you, you wont know ...
-
HTML: <div class="outer-container"> <div class="inner-container"> <div class="t...
No comments:
Post a Comment