Generally, unless you are using a hash table instead, not sorting in some way or another (be it directly on the array or a copy thereof, or by the use of a balanced binary tree) will be slower in the long run.Originally Posted by 7heavens
Generally, unless you are using a hash table instead, not sorting in some way or another (be it directly on the array or a copy thereof, or by the use of a balanced binary tree) will be slower in the long run.Originally Posted by 7heavens
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
It would be far safer to remove the assumption that -1 is never used. Instead of allocating an additional int array, you can just use a vector<bool> and set the right entry to true when you've found the item.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"