小编Yon*_*oni的帖子

在O(lgn)中搜索部分排序的数组

我很难解决这个问题.

A[1..n] is an array of real numbers which is partially sorted:
There are some p,q  (1 <= p <= q <=n) so:
A[1] <= ... <= A[p]
A[p] >= ... >= A[q]
A[q] <= ... <= A[n]

How can we find a value in this array in O(lgn)?
(You can assume that the value exists in the array)
Run Code Online (Sandbox Code Playgroud)

arrays algorithm search binary-search

5
推荐指数
1
解决办法
978
查看次数

标签 统计

algorithm ×1

arrays ×1

binary-search ×1

search ×1