Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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