Files
college-C/25 - Trees/ex1.c
2022-02-25 15:33:16 +02:00

44 lines
822 B
C

#include "General.h"
void InsertToBinaryTree(BinaryTree ** root, int k)
{
if (root == NULL)
{
MakeBinaryTree(root);
(*root)->info.int_ = k;
}
else if ((*root)->info.int_ > k)
{
if ((*root)->left == NULL)
{
AddLeftAfterBinaryTree(*root);
(*root)->left->info.int_ = k;
}
else
{
InsertToBinaryTree(&((*root)->left), k);
}
}
else if ((*root)->info.int_ < k)
{
if ((*root)->right == NULL)
{
AddRightAfterBinaryTree(*root);
(*root)->right->info.int_ = k;
}
else
{
InsertToBinaryTree(&((*root)->right), k);
}
}
else
{
printf("Duplicate!\n");
}
}
void main(void)
{
BinaryTree * bt;
}