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
This is a discussion on Equality of 2 Arrays within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by 7heavens I wanted to do it without sorting.. Generally, unless you are using a hash table instead, ...
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
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
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"