Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BST* addWord(BST* node, char* tword, int x){
- if(node == NULL){
- node = (BST*) malloc(sizeof(BST));
- //memset(node, NULL, sizeof(BST));
- node->word = tword;
- node->count = 1;
- node->left = node->right = NULL;
- ListItem* p = NULL;
- p = (ListItem*) malloc(sizeof(ListItem));
- memset(p, NULL, sizeof(ListItem));
- p->value = x;
- node->pHead = p;
- node->pTail = p;
- return node;
- }
- int cmp = stricmp( tword, node->word );
- if( cmp < 0 ){
- node->left = addWord(node->left, tword, x);
- }else if( cmp > 0 ){
- node->right = addWord(node->right, tword, x);
- }else{
- addToList( &(node->pTail), x);
- (node->count)++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement