@Richa Okey.. For this scenario, Extracting a node => output the root node, decrement its frequency count and remove the root node only if frequency count becomes 0. Heapify. Adding a node => locate a node which corresponds to same character as the inserted char in O(N) time, if it exists and increment its frequency count. Else create a new node with frequency count 1 and character = <new_char_input_by_user> and add i to the heap.
Given the above description above I think the input cases pointed out by you can be worked out. _dufus On Aug 17, 12:15 am, richa gupta <richa.cs...@gmail.com> wrote: > @dufus : > > suppose the words occurs like ( at the last of the document or u can say > that in the window of size N , the scenario is ) > l, b,b,b, c , d,d, e a > so ur max heap will make it > b(3) > d(2) c(1) > e(1) a (1) l(1) > > now explain me what happens when b or d or some new word "m" > > 2009/8/16 Miroslav Balaz <gpsla...@googlemail.com> > > > > > I think the teoreticaly easiest solution is to have two balanced binary > > search trees interlinked. on for finding by string, second for keeping count > > second can keep subtree sizes, and every time you check the position and if > > it changes then you can update list, you do not have to make more > > computation than is needed to redraw screen and to maintain balanced tree. > > > 2009/8/14 richa gupta <richa.cs...@gmail.com> > > >> You have to develop a piece of code that can be attached to a program > >> like Microsoft Word, which would list the last "N" words of the > >> document in descending order of their occurence, and update the list > >> as the user types. What code would you write? Using pseudo code is > >> fine, just list the basic things you would consider > > >> -- > >> Richa Gupta > >> (IT-BHU,India) > > -- > Richa Gupta > (IT-BHU,India) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---