[R] detecting if a variable has changed

S Ellison S.Ellison at LGCGroup.com
Tue Jun 14 17:55:06 CEST 2016


> > Nope, Ted. I asked for  a O(log(n)) solution, not an O(n) one.
> 
> I don't think that's possible with a numeric vector.  Inserting an entry
> at a random location is an O(n) operation, since you need to move all
> following values out of the way.

If the vector is presorted, wouldn't a binary search find the correct location in O(log(n))? (roughly log2(n)?) 

After that any insertion depends on how fast R can move memory about so the overall speed clearly depends on factors other than finding the location. 

S Ellison

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list