Skip to content

Instantly share code, notes, and snippets.

@pgsin
Created June 3, 2020 21:15
Show Gist options
  • Save pgsin/38322d275aafdbd8f29ecf644260dd5a to your computer and use it in GitHub Desktop.
Save pgsin/38322d275aafdbd8f29ecf644260dd5a to your computer and use it in GitHub Desktop.
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