#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
struct element{
struct element *parent;
int k;
struct element *right;
struct element *left;
};
struct element *BST_wstaw(struct element *root,struct element *nowy);
void inorder(struct element *root);
int main(){
struct element *root=NULL;
struct element *nowy=NULL;
int liczba,i=0;
while(i<5){
printf("Podaj lliczbe");
scanf("%d",&liczba);
nowy = (struct element*)malloc(sizeof(struct wezel));
nowy->k=liczba;
nowy->left=NULL;
nowy->right=NULL;
root=BST_wstaw(root,nowy);
i++;
}
inorder(root);
getch();
return 0;
}
struct element* BST_wstaw(struct element *root,struct element *nowy){
struct element* y= NULL,*x=root;
while(x!=NULL){
y=x;
if(x->k < nowy->k) x=x->right;
else x=x->left;
}
nowy -> parent = y;
if(y==NULL) root=nowy;
else if(nowy->k < y-> k) y->left=nowy;
else y->right=nowy;
return root;
}
void inorder(struct wezel *root){
if(root!=NULL){
inorder(root->left);
printf("%d ",root->k);
inorder(root->right);
}
}
struct element* usun(struct element *root,struct element *nowy)
{
struct element* y;
if(nowy->left=NULL || nowy->right=NULL)
y=nowy;
else y=nastepnik(root);
if(y->left!=NULL)
x=y=>left;
else x=y->right;
if(x!=NULL)
x->parent=y->parent;
if y->p=NULL
struct element* nastepnik(struct element*x)
{
struct element* y;
if x->right!=NULL;
return min(x->right);
y=x->parent;
while(y!=NULL && x==y->right)
{
x=y;
y=y->parent;
}
return y;
}
struct element* min(struct element*x)
{
if (x->left==NULL)
return x;
else return min(x->left);
}
{"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"}