nodePtr searchN(char* word, nodePtr leaf) { if (leaf == NULL) return NULL; if (strcmp(word, leaf->info.word)==0) return leaf; else if (strcmp(word,leaf->info.word) > 0) return searchN(word, leaf->right); else return searchN(word, leaf->left); }
int findN(unsigned int* a) { int i = 1; while(1) { if(a[i] > a[i+1]) { if(a[i+1] == 0) return i-1; else return i; } else if(a[i] < a[i+1]) { i = i*2; } else if(a[i] == 0) return searchN(a,(i/2)); } }
nodePtr worker(char* word, nodePtr tree) { nodePtr aux; int i, size = strlen(word); for (i = 0; i < size; i++) word[i] = tolower(word[i]); aux = searchN(word, tree); if (aux) aux->info.counter++; else tree = addNode(word, tree); return tree; }