Guys, you both are correct to some extent
dict is basically a map of key and values. And a Map can have either of the two implementation -- Hash : where the key is hashed and stored -- Red Black tree: where the key is stored in a RedBlack balanced tree per the comparative value of key. Hope this helps Regards, Rajesh Nair On Mon, May 24, 2010 at 12:03 PM, Mikhail Dektyarev < [email protected]> wrote: > For example, in C++ (at least in gcc libraries) std::map uses RB tree: > <...> > typedef _Rb_tree<key_type, value_type, _Select1st<value_type>, > key_compare, _Pair_alloc_type> _Rep_type; > > /// The actual tree structure. > _Rep_type _M_t; > <...> > > On Mon, May 24, 2010 at 1:53 AM, Atanas Banov <[email protected]> wrote: > >> dict uses trees, in what language that? >> seems you are mistaken, dictionaries *are* hashes >> >> >> >> On Sun, May 23, 2010 at 1:19 AM, Mikhail Dektyarev < >> [email protected]> wrote: >> >>> As I know, dict uses trees, not hashes. >>> And to find the right size is not difficult. 501x501 will be enough, >>> filling with 0 by default. >>> >>> On Sun, May 23, 2010 at 12:17 PM, Atanas Banov <[email protected]> wrote: >>> >>>> errr, no. hash lookup is O(1), not log... you are thinking balanced >>>> trees or some such. >>>> also while 2D array will be a bit faster, you will have to deal with >>>> proper sizing and filling default value. >>>> >>>> >>>> On Sat, May 22, 2010 at 8:18 PM, Terence <[email protected]> wrote: >>>> >>>>> Another point is to use array (2-D list) instead of dict to implement >>>>> cache. this will reduce the time complexity of cache lookup operation from >>>>> O(logN) to O(1) >>>>> >>>>> >>>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "google-codejam" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<google-code%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/google-code?hl=en. >> > > > > -- > Best regards, Дектярев Михаил > > -- > You received this message because you are subscribed to the Google Groups > "google-codejam" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-code%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-code?hl=en. > -- You received this message because you are subscribed to the Google Groups "google-codejam" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-code?hl=en.
