Is binary search an O (logN) ordered list in Elixir?

For an ordered list, the complexity of the binary search time is O (logN). However, in Elixir, a list is linked by a list, so to get the middle element of the list, you need to repeat N / 2 times, which makes the general O (NLogN) search.

So my question is:

  • Is the time complexity correctly exceeded?
  • If this is correct, binary search does not make sense in Elixir, right? You have to iterate over the list to get what you want, so O (N) is best.
+4
source share
1 answer

, - , . ( ).

, , , , . , , (O(N * log(N))), (O(log(N))), O(N).

+3

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


All Articles