using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp10
{
public class DrzewoBST
{
BST root = null;
BST tmp;
int dlugosc = 0;
public void Push(int liczba)
{
BST nowy = new BST();
nowy.wartosc = liczba;
tmp = root;
if (root == null) root = nowy;
else{
tmp = root;
if (nowy.wartosc < tmp.wartosc)
{
while (tmp.lewe != null)
{
tmp = tmp.lewe;
}
tmp.lewe = nowy;
dlugosc++;
}
if (nowy.wartosc > tmp.wartosc)
{
while (tmp.prawe != null)
{
tmp = tmp.prawe;
}
tmp.prawe = nowy;
dlugosc++;
}
}
}
public void Pop(int liczba)
{
tmp = root;
while(tmp != null)
{
tmp = tmp.lewe;
if (root.wartosc == liczba)
{
Console.WriteLine("FOUND");
tmp = null;
}
}
}
public void Lenght()
{
Console.WriteLine("Ilosc: " + dlugosc);
}
public void Show()
{
Console.WriteLine("--------------------");
Pokaz(root);
}
public void Pokaz(BST Root)
{
if (Root != null)
{
Console.WriteLine(Root.wartosc);
Pokaz(Root.lewe);
Pokaz(Root.prawe);
}
}
}
public class BST
{
public BST lewe;
public BST prawe;
public int wartosc;
}
class Program
{
static void Main(string[] args)
{
DrzewoBST Drzewo = new DrzewoBST();
Drzewo.Push(8);
Drzewo.Push(5);
Drzewo.Push(12);
Drzewo.Push(7);
Drzewo.Push(4);
Drzewo.Push(15);
Drzewo.Push(11);
Drzewo.Show();
Drzewo.Pop(4);
Drzewo.Show();
Console.ReadLine();
}
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}