Advertisement
jtentor

BTNode.cs - 1.00

Nov 12th, 2015
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.71 KB | None | 0 0
  1. using System;
  2.  
  3. namespace DemoBinaryTree
  4. {
  5.     /// <summary>
  6.     /// Implementación del Nodo para un árbol binario
  7.     /// </summary>
  8.     /// <typeparam name="E">Tipo de dato del elemento que se referencia en cada nodo</typeparam>
  9.     public class BTNode<E>
  10.     {
  11.         private E item;
  12.         public virtual E Item
  13.         {
  14.             get { return this.item; }
  15.             set { this.item = value; }
  16.         }
  17.         private BTNode<E> left;
  18.         public virtual BTNode<E> Left
  19.         {
  20.             get { return this.left; }
  21.             set { this.left = value; }
  22.         }
  23.         private BTNode<E> right;
  24.         public virtual BTNode<E> Right
  25.         {
  26.             get { return this.right; }
  27.             set { this.right = value; }
  28.         }
  29.  
  30.         /// <summary>
  31.         /// Constructor por defecto con valores por defecto
  32.         /// Constructor especializado, permite fijar el elemento del nodo
  33.         /// y el valor de los enlaces a subárboles izquierdo y derecho
  34.         /// </summary>
  35.         /// <param name="item">Elemento en el nodo</param>
  36.         /// <param name="next">Enlace al subárbol izquierdo</param>
  37.         /// <param name="prev">Enlace al subárbol derecho</param>
  38.         public BTNode(E item = default(E), BTNode<E> left = null, BTNode<E> right = null)
  39.         {
  40.             this.Item = item;
  41.             this.Left = left;
  42.             this.Right = right;
  43.         }
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.         /// <summary>
  58.         /// Metodo para probar las distintas formas en que
  59.         /// se puede recorrer un árbol
  60.         /// </summary>
  61.         public virtual void Visit()
  62.         {
  63.             Console.Write("{0} ", this.Item.ToString());
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement