Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the time complexity of name look-up in an R list?

I have tried desperately to find the answer via Google and failed. I am about to do the benchmark myself but thought that maybe someone here knows the answer a or at least a reference where this is documented.

To expand on my question: suppose I have a list L in R of length N, where N is rather large (say, 10000, 100.000, 1 million or more). Assume my list has names for every element. `

I wonder how long does it take to retrieve a single named entry, i.e, to do

 L[[ "any_random_name" ]]  

Is this time O(N), i.e. proportional to the length of the list, or is it O(1), that is, constant independent of the name of the list. or is it maybe O( log N ) ?

like image 950
Mateo Avatar asked Dec 27 '16 23:12

Mateo


People also ask

What is the complexity of searching for an element on a list?

complexity for list is O(n) and for set it is O(1) which is constant.

What is the time complexity of A * search?

The time complexity of A* depends on the heuristic. In the worst case of an unbounded search space, the number of nodes expanded is exponential in the depth of the solution (the shortest path) d: O(bd), where b is the branching factor (the average number of successors per state).


1 Answers

The worst case for name lookup is O(n). Take a look here: https://www.refsmmat.com/posts/2016-09-12-r-lists.html .

like image 50
jidicula Avatar answered Sep 22 '22 07:09

jidicula