What is the fastest search you can do on an unsorted array?

How to quickly search in an unordered array? I can’t think of any other search mechanisms than linear search.

Any pointers would be helpful.

+3
source share
8 answers

Yes, without sorting the data, a linear search is about as good as you can.

+7
source

Given a truly random, not sorted array, a linear search is the best way.

You may be able to improve some heuristic approach if the data can be considered roughly sorted.

+4
source

. .

+3

. - . .

+1

, - . , , .

, , . , lookup() ( -), .

, ?

? , ? , . , . ? , , ?

? ? , 1000 . , .

. , , , .

+1

, , . (.. + ).

+1

, , .

, , , .

-, , . , .

-, . , , , .

, . , , .

0

If you are able, you might consider changing the way you store and create data in the first place. Instead of adding elements to the array, create a complete binary tree (or something else) and work with it. This makes data manipulation a little slower, but it should not be as slow as re-sorting the data every time and will make your searches much faster.

0
source

Source: https://habr.com/ru/post/1748845/


All Articles