using System.Collections.Generic;
public int Value { get; set; }
public Node Left { get; set; }
public Node Right { get; set; }
public static void Insert(Node root, int value)
root.Left = new Node(value);
Insert(root.Left, value);
root.Right = new Node(value);
Insert(root.Right, value);
public static void BFS(Node root)
Queue<Node> queue = new Queue<Node>();
Node current = queue.Dequeue();
Console.Write(current.Value + " ");
if (current.Left != null)
queue.Enqueue(current.Left);
if (current.Right != null)
queue.Enqueue(current.Right);
public static void DFS(Node root)
Console.Write(root.Value + " ");
public static void Main()
Console.WriteLine("Hello World");
Random random = new Random();
Node tree = new Node(10);
for (int i = 0; i < 10; i++)
var rnd = random.Next(0, 20);
Console.Write(rnd + " ");
Console.WriteLine("BFS:");
Console.WriteLine("DFS:");