Ruby function to calculate average search time for a skip list -


i'm trying write ruby function determine average expected search time skip list. don't have strong math background , believe results i'm getting function not correct.

n = number of elements in list

base = denominator of promotion probability. i.e. if 1 of 4 nodes promoted base = 4

def lookup_eficiency(n, base)   return (math.log(n, base)*(base/2.0)) end 

how express equation in ruby take number of elements in skip-list , base , return average search time?

since complexity of skip list o(logbase(n/base)), how ?

def lookup_efficiency(n, base)   math.log(n/base)/math.log(base) end 

make sure base float don't end integer division !


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -