dual key hashmap <actor,film> Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652
On Sun, Apr 8, 2012 at 2:37 PM, bharat b <bagana.bharatku...@gmail.com>wrote: > Maintain an vector of structure "Film_actors" for "List of actors" > Maintain an vector of structure "Actor_films" for "List of Films" > I'll explain this with the help of an example . > Films: > 1.Hai > 2.Bye > Actors: > A,B,C,D acted in Film Hai. > A,D,F,G acted in Film Bye. > > struct Film_actors { > String Film_name; > int * list_of_actors; // indices in other datastructure .. > int number_of_actors; > }; > create hashtable on actor'sNames and filmNames.. > "List_of_actors" is as follows > add new film in this list and check whether the actor 'A' is already in > hash table., if not add 'A' to hash table<A,index in List_of_Films data > structure> > when ever we add a new film to List_of_actors[], we add that FilmName to > hash table<filmname,index in List_of_actors datastructure>. > > List_of_actors[0] = {"Hai",{0,1,2,3},4}; > List_of_actors[1] = {"Bye",{0,3,4,5},4}; > > struct Actor_films { > String Actor_name; > int * list_of_films; // indices(values in hash table on films) in other > data structure > int number_of_films; > }; > With these data structures, we can do all operations in O(1) time .. > if any mistakes, let me know ... > > > On Fri, Apr 6, 2012 at 10:50 PM, Rose <itro...@gmail.com> wrote: > >> Thanks all of you. I'm new to algorithms and data structure and I'm new >> in this forum. >> I have an assignment but not sure yet: >> >> A. Describe a data structure which can effectively answer the following >> questions: >> >> 1. A list of actors (f) : Print a list of actors who took part in film*f >> *. >> 2. A list of films -(s): Print a list with all the films that actor s has >> been in. >> 3. Participation (s,f): Return true if the actor s took part in film f, >> and false if not. >> >> Explain the data structure and how the questioning is done. >> Analyse the worst case running time for the above queries- in asymptotic >> notation, as tight as possible >> >> In the analysis use e.g. F=number of films; S =number of actors; Fs= >> number of films actor s took part in; >> and Sf =number of actors who took part in film f. >> >> Thanks a lot for your help >> >> -- >> Med Venlig Hilsen/Kind regards >> >> Rose >> >> >> >> -- >> 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?hl=en. >> > > -- > 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?hl=en. > -- 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?hl=en.