Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace BinaryTree
- {
- class BinNode<T>
- {
- private T value;
- private BinNode<T> left, right;
- public BinNode(BinNode<T> left, T value, BinNode<T> right)
- {
- this.value = value;
- this.left = left;
- this.right = right;
- }
- public BinNode(T value) : this(null, value, null) { }
- public T GetValue()
- {
- return this.value;
- }
- public BinNode<T> GetLeft()
- {
- return this.left;
- }
- public BinNode<T> GetRight()
- {
- return this.right;
- }
- public bool HasLeft()
- {
- return this.left != null;
- }
- public bool HasRight()
- {
- return this.right != null;
- }
- public void SetValue(T value)
- {
- this.value = value;
- }
- public void SetLeft(BinNode<T> left)
- {
- this.left = left;
- }
- public void SetRight(BinNode<T> right)
- {
- this.right = right;
- }
- public override string ToString()
- {
- return this.value.ToString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement