Please mention time complexity and best data structure to store these values, when values are:
- Integers
- Strings (dictionary like sorting)
I know Counting sort is preferred when integers are in a small range.
Thanks.
Edit:
Sorry, I asked a bit different question. Actual question is what would be the best data structure to store these values, if the integers are phone numbers (and strings are names) and then find the best sorting algorithm.
Have a look at:
Btrees and red-black trees.
You should be able to find open source implementations of each of these. (Note, I’m assuming that you want to maintain a sorted structure, rather than just sorting once and forgetting.)