Left Skewed Tree


class App
{
public App()
{
BinaryTree bt = new BinaryTree();
Node root = bt.AddChild(bt.Root, 1);
Node nodeB = bt.AddChild(root, 2);
Node nodeC = bt.AddChild(nodeB, 3);
Node nodeD = bt.AddChild(nodeC, 4);
}
}

Recursive Print

public void Print(Node root)
{
if (root == null) return;
Console.WriteLine("Print: {0}", root.Data);
PrintRecursive(root.Left);
}
private void PrintRecursive(Node root)
{
if (root == null) return;
Console.WriteLine("Print: {0}", root.Data);
PrintRecursive(root.Left);
}

'C# > 수업 내용' 카테고리의 다른 글
| [C#] 이진 트리 pre-order(전위 순회) (0) | 2021.09.30 |
|---|---|
| [C#] 배열 Binary Tree (0) | 2021.09.29 |
| [C#] 이진 트리 level order traversal (0) | 2021.09.27 |
| [C#] 일반 트리 level order traversal (0) | 2021.09.26 |
| [C#] Tree (0) | 2021.09.24 |