public void addnod(nod <T> n) { Type X = n.GetType(); arb[nnod] = new nod <T>(n); nnod++; }
public nod(nod <T> n) { val = n.val; par = n.par; fs = n.fs; fd = n.fd; }
private void swap(nod <T> x, nod <T> y) { T a = x.val; x.val = y.val; y.val = a; }
public void postoAfis(nod <T> r) //SDR { if (r != null) { postoAfis(r.fs); postoAfis(r.fd); Console.Write(r.val + " "); } }
public void inoAfis(nod <T> r) //SRD { if (r != null) { inoAfis(r.fs); Console.Write(r.val + " "); inoAfis(r.fd); } }
public void preoAfis(nod <T> r) //RSD { if (r != null) { Console.Write(r.val + " "); preoAfis(r.fs); preoAfis(r.fd); } }
public nod(T v, nod <T> p) { val = v; par = p; if (p.fs != null && p.fd != null) { Console.WriteLine("ERR:ta deja are 2 copchii !!"); } else if (p.fs == null) { p.fs = this; } else { p.fd = this; } }
public void addnod(T x) { arb[nnod] = new nod <T>(x); if (nnod != 0) { if (nnod % 2 == 0) { arb[nnod].par = arb[(nnod - 2) / 2]; arb[(nnod - 2) / 2].fd = arb[nnod]; } else { arb[nnod].par = arb[(nnod - 1) / 2]; arb[(nnod - 1) / 2].fs = arb[nnod]; } } nnod++; }