Analysis Of Algorithms University of Bridgeport Analysis of Algorithms



Download 3.4 Mb.
Page9/33
Date28.05.2018
Size3.4 Mb.
#51061
1   ...   5   6   7   8   9   10   11   12   ...   33
V
failure
ariation: Linear Search with Ordered Array (early stop possible)

Here,



i

Instance

pi

Ti(n)

1

x = A[1]

p/n

1

2

x = A[2]

p/n

2

i

x = A[i]

p/n

i
success


n

x = A[n]

p/n

n

n+1

x < A[1]

(1 – p)/n

1

n+2

x < A[2]

(1 – p)/n

2

j

x < A[j]

(1 – p)/n

j

2n-1

x < A[2n-1]

(1 – p)/n

n-1

2n

x < A[n]

(1 – p)/n

n

For linear search with ordered array,



A(n) =

= =

=

=
= =


Download 3.4 Mb.

Share with your friends:
1   ...   5   6   7   8   9   10   11   12   ...   33




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

    Main page