python - How does the look up time of nested dictionaries increase? -


can comment on how complexity of dictionaries increases "nest" them further?

e.g add element follows:

dict_name[a][b][c][d] = 0 

i think lookup time should same dictionary (constant time o(1)), change if add elements this?

dict_name[a][b][c]....[z] 

python's dictionary implementation doesn't change nesting, no, algorithmic complexity of lookup not change. far python concerned, each [key] subscription independent object subscribing came from.

each lookup still o(1). looking nested element depth times o(1) lookup. since hard-coded depth (by using literal notation), have still o(1) constant multiplier doesn't affect big-o complexity.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -