I have an array containing names of items. I want to give the user the option to create items without specifying their name, so my program will have to supply a unique defau
You could try to do the following:
first:
So now you have built up a map with the used numbers, with complexity "N x log(N)"
Next, iterate to the tree and as soon you see a 'hole', use the number. Worst case is complexity N.
So in total, the complexity is N x log(N) + N, or simplified: N log(N).