Advertisement
Guest User

Bintree

a guest
Jan 24th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8. class node<T>
  9. {
  10. private T Value;
  11. private node<T> next;
  12. public node(T X)
  13. {
  14. this.Value = X;
  15. this.next = null;
  16. }
  17. public node(T X, node<T> next)
  18. {
  19. this.Value = X;
  20. this.next = next;
  21. }
  22. public T GetValue()
  23. {
  24. return this.Value;
  25. }
  26. public node<T> GetNext()
  27. {
  28. return this.next;
  29. }
  30. public void SetValue(T x)
  31. {
  32. this.Value = x;
  33. }
  34. public void SetNext(node<T> next)
  35. {
  36. this.next = next;
  37. }
  38. public bool HasNext()
  39. {
  40. if (this.next == null)
  41. {
  42. return false;
  43. }
  44. return true;
  45. }
  46. public override string ToString()
  47. {
  48. return "(the value is " + this.Value + ")";
  49. }
  50. }
  51.  
  52. class BiNode <T>
  53. {
  54. private T Value;
  55. private BiNode<T> Right;
  56. private BiNode<T> Left;
  57. public BiNode(T Value)
  58. {
  59. this.Value = Value;
  60. }
  61. public BiNode(T Value, BiNode<T> Right, BiNode<T> Left)
  62. {
  63. this.Value = Value;
  64. this.Right = Right;
  65. this.Left = Left;
  66. }
  67. public T GetValue ()
  68. {
  69. return Value;
  70. }
  71. public void SetValue(T Value)
  72. {
  73. this.Value = Value;
  74. }
  75. public BiNode<T> GetRight()
  76. {
  77. return Right;
  78. }
  79. public BiNode<T> GetLeft()
  80. {
  81. return Left;
  82. }
  83. public void SetLeft(BiNode<T> Left)
  84. {
  85. this.Left = Left;
  86. }
  87. public void SetRight(BiNode<T> Right)
  88. {
  89. this.Right = Right;
  90. }
  91. public bool HasRight()
  92. {
  93. if (this.Right == null)
  94. return false;
  95. return true;
  96. }
  97. public bool HasLeft()
  98. {
  99. if (this.Left == null)
  100. return false;
  101. return true;
  102. }
  103. }
  104.  
  105. class Program
  106. {
  107. static void Main(string[] args)
  108. {
  109. }
  110. }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement