public node addAuTo(node n) { if (len == 0) return null; else return addA(rad, n); }
private void addF(node n, Dictionary<string, string[]> d) { if (d[n.Text][0] != "null") { a.addSt(n, Convert.ToDouble(d[n.Text][0])); addF(n.nst, d); } if (d[n.Text][1] != "null") { a.addDr(n, Convert.ToDouble(d[n.Text][1])); addF(n.ndr, d); } }
private void baddAuto_Click(object sender, EventArgs e) { double x = Convert.ToDouble(tbaddAuto.Text); if (sb != null) sb.BackColor = Color.LightBlue; sb = a.addAuTo(x); if (x < sb.val) crStNode(x); else crDrNode(x); sb = null; reset(); tbaddAuto.Text = string.Empty; }
private node addA(node t, double v) { if (t.val > v) { if (t.nst == null) return t; else return addA(t.nst, v); } else { if (t.ndr == null) return t; else return addA(t.ndr, v); } }
private node addA(node t, node n) { if (t.val > n.val) { if (t.nst == null) return t; else return addA(t.nst, n); } else { if (t.ndr == null) return t; else return addA(t.ndr, n); } }
public void swap(node n1, node n2) { double ax=n1.val; n1.val = n2.val; n2.val = ax; }
public void delete(node n) { if (n != null) { if (n.ndr == null) { if (n.nst == null) { if (len<=1) { rad = new node(); rad.Text = "--"; len = 0; } else { n.Dispose(); if (n.par.ndr == n) n.par.ndr = null; else n.par.nst = null; len--; } } else { n.val = n.nst.val; delete(n.nst); } } else { n.val = n.ndr.val; delete(n.ndr); } } }
private void bsort_Click(object sender, EventArgs e) { a.sort(); if (sb != null) sb.BackColor = Color.LightBlue; sb = null; reset(); }
public arb(double v) { rad = new node(v); len = 1; ord = true; }
private void init() { node b = new node(11); b.Location = new Point(Width/2-25, 10); arbpanel.Controls.Add(b); b.Click += delegate(object sender, EventArgs e) { if (sb != null) sb.BackColor = Color.LightBlue; sb = sender as node; sb.BackColor = Color.LightPink; reset(); }; a = new arb(b); }
private void erase() { arbpanel.Dispose(); arbpanel = new Panel(); arbpanel.BackColor = Color.White; arbpanel.Width = 1887; arbpanel.Height = 212; Controls.Add(arbpanel); sb = null; lol2(); }
private void display(node b, Point p) { int l = p.Y / 35 + 2; b.Location = p; arbpanel.Controls.Add(b); b.Click += delegate(object sender, EventArgs e) { if (sb != null) sb.BackColor = Color.LightBlue; sb = sender as node; sb.BackColor = Color.LightPink; reset(); }; if (b.nst != null) display(b.nst, new Point((int)(p.X - Width / Math.Pow(2, l)), (l - 1) * 35)); if (b.ndr != null) display(b.ndr, new Point((int)(p.X + Width / Math.Pow(2, l)), (l - 1) * 35)); }
private void crStNode(double v) { int l = sb.Location.Y / 35 + 2; if (l < 7) { node b = new node(v); b.Location = new Point((int)(sb.Location.X - Width / Math.Pow(2, l)), (l - 1) * 35); arbpanel.Controls.Add(b); b.Click += delegate(object sender, EventArgs e) { if (sb != null) sb.BackColor = Color.LightBlue; sb = sender as node; sb.BackColor = Color.LightPink; reset(); }; a.addSt(sb, b); } else MessageBox.Show("Depth limit reached !"); }
private node sh(node n, double v) { if (n == null) return null; if (n.val == v) return n; else if (n.val > v) return sh(n.nst, v); else return sh(n.ndr, v); }
public void addDr(node pr, node c) { if (pr.ndr == null) { pr.ndr = c; c.par = pr; len++; } ord = false; }
private void srt(node n,node inf,node sup) { if (inf != null) if (n.val < inf.val) { ord = false; swap(n, inf); } if (sup != null) if (n.val > sup.val) { ord = false; swap(n, sup); } if(n.nst!=null) srt(n.nst, inf, n); if(n.ndr!=null) srt(n.ndr, n, sup); }
public void addSt(node pr, double v) { if (pr.nst == null) { pr.nst = new node(v); pr.nst.par = pr; len++; } ord = false; }
public arb(node r) { rad = r; len = 1; ord = true; }
public void addSt(node pr, node c) { if (pr.nst == null) { pr.nst = c; c.par = pr; len++; } ord = false; }
public void addDr(node pr, double v) { if (pr.ndr == null) { pr.ndr = new node(v); pr.ndr.par = pr; len++; } ord = false; }
private void bsearch_Click(object sender, EventArgs e) { if (sb != null) sb.BackColor = Color.LightBlue; sb = a.search(Convert.ToDouble(tbsearch.Text)); if (sb == null) MessageBox.Show("Not Found !"); else { sb.BackColor = Color.LightPink; reset(); } tbsearch.Text = string.Empty; }