void printStatistic(HashTable *hashTable){ printf("Load Factor is %.10f\n", findLoadFactor(hashTable)); printf("The middle lenght is %.10f\n", middleLength(hashTable)); printf("Max chain's length is %d\n", findMaxLength(hashTable)); printf("Words in a max chain : "); printAllWords(hashTable, findMaxLength(hashTable)); printf("The number of different added words is %d\n", numOfAddedWords(hashTable)); printf("The number of empty cell's is %d\n", numberOfEmptyCell(hashTable)); }
void findMaxLength(Node * root) { if (root == NULL) { return; } if (root->left == NULL) { root->maxLeft = 0; } else { findMaxLength(root->left); } if (root->right == NULL) { root->maxRight = 0; } else { findMaxLength(root->right); } if (root->left != NULL) { int tempMax = 0; if (root->left->maxLeft > root->left->maxRight) { tempMax = root->left->maxLeft; } else { tempMax = root->left->maxRight; } root->maxLeft = tempMax + 1; } if (root->right) { int tempMax = 0; if (root->right->maxLeft > root->right->maxRight) { tempMax = root->right->maxLeft; } else { tempMax = root->right->maxRight; } root->maxRight = tempMax + 1; } if (root->maxLeft + root->maxRight > maxLen) { maxLen = root->maxLeft + root->maxRight; } }