From: serg k. <in...@mt...> - 2000-10-19 21:23:38
|
Hi, all! Hi, Jim! >... >I can't assume a length of the longest word... No problem! Try to use RedBlackTrees ([Thomas Niemann. Sorting and Searching Algorithms:A Cookbook] c-sources there: http://odin.ee.uwa.edu.au/~morris/Year2/PLDS210/niemann/s_man.htm) with next {_node}: ... _node { ... int word_length; /* unsigned long long, may be? */ int word_counter; ... }; int curr_word_length; /* unsigned long long, may be? */ ... do {/******************************************************************/ ... curr_word_length=... if ((ptr_curr_node=find_node (curr_word_length, root)) == NULL) { ptr_curr_node=insert_node (curr_word_length, root); ptr_curr_node->word_counter=1; } else { ptr_curr_node->word_counter++; } ... }/******************************************************************/ while (!EOF); /* write obxod_tree () yourself */ obxod_tree (root); /* count nodes and get sorted list there... */ print_histogram (...); ... wbr, abn |