using System; namespace alcoran { public class BinaryNode { public int Value { get; set; } public BinaryNode Left { get; set; } public BinaryNode Right { get; set; } public BinaryNode(int value) { Value = value; Left = null; Right = null; } } public class BinaryTreeByLinkedList { public void PreOrder(BinaryNode node) { if (node == null) return; Console.WriteLine(node.Value + " "); PreOrder(node.Left); PreOrder(node.Right); } } class Program { public static void Main(string[] args) { BinaryNode root = new BinaryNode(1); root.Left = new BinaryNode(2); root.Right = new BinaryNode(3); root.Left.Left = new BinaryNode(4); root.Left.Right = new BinaryNode(5); BinaryTreeByLinkedList tree = new BinaryTreeByLinkedList(); Console.WriteLine("Preorder traversal of binary tree:"); tree.PreOrder(root); Console.ReadKey(true); } } }