KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Can anyone explain what is the complexity of the following Dictionary methods? ContainsKey(key) Add(key,value); I'm trying to figure out the complexity of a method I wrote: public void DistinctWords(String s) { Dictionary<string,string> d = new Dictionary<string,string>(); String[] splitted = s.split(" "); foreach ( String ss in splitted) { if (!d.containskey(ss)) d.add(ss,null); } } I assumed that the 2 dictionary methods are of log(n) complexity where n is the number of keys in the dictionary. Is this correct?
Tags (comma-separated)
Save Edits
Cancel