What is time complexity for find method in a set in C++?
-
I am inserting N strings each of length K. Had it been integers, the complexity would be log(N). But here we are storing strings, each of size K. What will be the complexity to find a string in this scenario?
-
Answer:
The complexity of std::set::find() being [math]O(log(n))[/math] simply means that there will be of the order of [math]log(n)[/math] comparisons of objects stored in the set. The actual complexity, therefore, would be [math]O(log(n) * k)[/math], since each comparison can be taken to be of the complexity [math]O(k)[/math].
Anmol Singh Jaggi at Quora Visit the source
Related Q & A:
- What TV show on real-life mysteries mentioned a child time-traveller in a photo of the Gettysburg Address?Best solution by Movies & TV
- How to set the C++ standard in eclipse?Best solution by stackoverflow.com
- What do I do to find a old article from a newspaper?Best solution by Yahoo! Answers
- What is the longest time anyone has ever been in a coma?Best solution by ChaCha
- What do they mean when they say it is a set up job?
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.