Created
June 3, 2020 21:15
-
-
Save pgsin/38322d275aafdbd8f29ecf644260dd5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace ConsoleApp9 { | |
public class BinaryTreeNode { | |
public int Data { get; } | |
public BinaryTreeNode Left { get; } | |
public BinaryTreeNode Right { get; } | |
public BinaryTreeNode(int data) { | |
Data = data; | |
Left = null; | |
Right = null; | |
} | |
public int Height() { | |
int leftHeight = 0; | |
int rightHeight = 0; | |
if (Left != null) { | |
leftHeight = Left.Height(); | |
} | |
if (Right != null) { | |
rightHeight = Right.Height(); | |
} | |
return Math.Max(leftHeight, rightHeight) + 1; | |
} | |
public bool IsLeaf() { | |
//TODO | |
return false; | |
} | |
public void Add(int data) { | |
//TODO | |
} | |
public bool Search(int data) { | |
//TODO | |
return false; | |
} | |
public void Print() { | |
//TODO using Console.Write | |
} | |
} | |
class Program { | |
static void Main(string[] args) { | |
//TODO test here | |
//BinaryTreeNode node = new BinaryTreeNode(10); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment