【活动】8月water 清凉一下/夏# Fashion - 美丽时尚
h*d
1 楼
Suppose each row of an n×n array A consists of 1’s and 0’s such that, in
any row i of A, all the 1’s come before any 0’s. Also suppose that the
number
of 1’s in row i is at least the number in row i+1, for i = 0,1, . . . ,n
8722;2.
Assuming A is already in memory, describe a method running in O(n)
time (not O(n2)) for counting the number of 1’s in A.
any row i of A, all the 1’s come before any 0’s. Also suppose that the
number
of 1’s in row i is at least the number in row i+1, for i = 0,1, . . . ,n
8722;2.
Assuming A is already in memory, describe a method running in O(n)
time (not O(n2)) for counting the number of 1’s in A.