Analysis Of Algorithms University of Bridgeport Analysis of Algorithms



Download 3.4 Mb.
Page17/33
Date28.05.2018
Size3.4 Mb.
#51061
1   ...   13   14   15   16   17   18   19   20   ...   33



Substituting, k = lg (n + 1) we have





Now combining both the terms we have,



AElementPresent (n) = []
Given that: p ≡ Pr (element exist in the array)
A(n) = p(average cost when element is present) + (1 – p) (worst cost)

= p[] + (1 – p) [lg(n+1)]

For example, if n = 1023,



A(n) = p[lg(1024) – 0.7213 + + (1 – p)[lg(1024)

= p(9.3) + (1 – p)(10)




Download 3.4 Mb.

Share with your friends:
1   ...   13   14   15   16   17   18   19   20   ...   33




The database is protected by copyright ©ininet.org 2024
send message

    Main page