using System;
class Node
{
public int Data;
public Node Left, Right;
}
class Trees
{
static void InSert(ref Node root, int newdata)
{
if (root == null)
{
root = new Node();
root.Data = newdata;
root.Left = null;
root.Right = null;
}
else if (newdata < root.Data) InSert(ref root.Left, newdata);
else if (newdata > root.Data) InSert(ref root.Right, newdata);
else Console.WriteLine("Error: Trung lap du lieu");
}
//Ham thuc hien cac chuc nang cua chuong trinh
static void Main()
{
Node root = null; int newdata;
double d = 0;
do
{
Console.Write("Ket thuc nhap nhan Enter");
newdata = int.Parse("0" + Console.ReadLine());
if (newdata != 0)
{
InSert(ref root, newdata);
d++;
}
} while (newdata != 0);
Console.Write("so nut la:" + d);
double ch = 0;
ch = Math.Log10(d + 1) / Math.Log10(2); ;
Console.Write("chieu cao cua 1 cay la:" + ch);
Console.ReadKey();
}
}
class Node
{
public int Data;
public Node Left, Right;
}
class Trees
{
static void InSert(ref Node root, int newdata)
{
if (root == null)
{
root = new Node();
root.Data = newdata;
root.Left = null;
root.Right = null;
}
else if (newdata < root.Data) InSert(ref root.Left, newdata);
else if (newdata > root.Data) InSert(ref root.Right, newdata);
else Console.WriteLine("Error: Trung lap du lieu");
}
//Ham thuc hien cac chuc nang cua chuong trinh
static void Main()
{
Node root = null; int newdata;
double d = 0;
do
{
Console.Write("Ket thuc nhap nhan Enter");
newdata = int.Parse("0" + Console.ReadLine());
if (newdata != 0)
{
InSert(ref root, newdata);
d++;
}
} while (newdata != 0);
Console.Write("so nut la:" + d);
double ch = 0;
ch = Math.Log10(d + 1) / Math.Log10(2); ;
Console.Write("chieu cao cua 1 cay la:" + ch);
Console.ReadKey();
}
}