def power (x, y) :
z = 1
m = 0
while m < y :
z = z * x
m = m + 1
return z
precondition : x ∈ ℝ, y ∈ ℕ
post-condition : x^y, z = x^y
PRE : A is sorted increasing, complete to x, |A| = n
POST : O ≤ p ≤ n, A[0, ... , p - 1] < x ≤ A[p, ... , n - 1]
so we need to consider 2 cases.
Case 1 : b (i+1) = m (i+1) + 1 and e(i + 1) = ei
Case 2 : e(i + 1) = m(i + 1) - 1, b(i + 1) = bi
bi ≤ m(i + 1) ≤ ei
No comments:
Post a Comment