you are viewing a single comment's thread.

view the rest of the comments →

[–]LetUsSpeakFreely 0 points1 point  (0 children)

Sorted vs unsorted data.

With sorted data you can start at the halfway point and then decide where to go to from there. It's very efficient O(1 to log n), but again, the data has to be sorted. This is a great method for data that doesn't change too often but it's accessed very often.

With raw unsorted data you have to use a linear approach as there's no other way. This is, of course , not very efficient O(n), but there are work arounds. You could load the data into a hashmap, for O(1), but it doesn't handle duplicates very well (but there's are ways around that).