Witam!
mam takie 3 algorytmy:
//Deklaracja funkcji INSERT
TREE insert(ETYPE x, TREE T)
{
if (T == NULL)
{
T = (TREE) malloc(sizeof(struct NODE));
T->element = x;
T->left = NULL;
T->right = NULL;
}
else if (x < T->element)
T->left = insert(x, T->left);
else if (x > T->element)
T->right = insert(x, T->right);
return T;
}
//Deklaracja funkcji DELETE_TREE
TREE delete_tree(TREE T, ETYPE del, int lvl)
{
if(!T) return 0;
if (T->element!=del)
root2 = insert(T->element, root2);
delete_tree(T->left, lvl+1, del);
delete_tree(T->right, lvl+1, del);
return root2;
//Deklaracja funkcji FIND_TREE
int find(TREE T, ETYPE c, int LVL)
{
if (T==NULL)
return FALSE;
else
{
if (T->element==c)
return LVL;
if (T->element < c)
return find(T->right,c,LVL+1);
if (T->element > c)
return find(T->left,c,LVL+1);
}
}
Dla każdego z nich musze obliczyć złożoność w ort!, najgorszym i średnim przypadku.
będe wdzięczny za wszelką pomoc, wskazówke, punkt zaczepienia...
Pozdrawiam