/********************************************************************
Function prototypes.
********************************************************************/
void Insert_1_Key (TreePtr *);
void Insert_Manually_Keys (TreePtr *);
void Insert_Random_Keys (TreePtr *);
void insert (TreePtr *,int);
/*******************************************************************
This function insert 1 key to tree.
*******************************************************************/
void Insert_1_Key (TreePtr *tree)
{
TreePtr temp;
int key;
clrscr();
printf("Plzzz enter key : \n");
scanf("%d",&key);
insert(*(&tree),key);
}
void insert (TreePtr *tree,int value)
{
if ( *tree == NULL ) /* *treePtr is NULL */
{
*tree = malloc( sizeof( TreePtr ) );
if ( *tree != NULL )
{
( *tree )->data = value;
( *tree )->left = NULL;
( *tree )->right = NULL;
}
else
printf( "%d not inserted. No memory available.\n",
value );
}
else
if ( value < ( *tree )->data )
insert( & ((*tree)->left) , value );
else if ( value > ( *tree )->data )
insert( &(( *tree) ->right) , value );
else
printf( "dup" );
}هاي لوسمحتم انا عندي داله اسمها insert شغاله مافيها شي بس لمن ادذلها باراميتر من Insert_1_Key ماتظبط وياي ممكن احد يساعدني ويوقولي ايش غلط وشكرا.