我有一个已旋转的排序列表,并希望在该列表上进行二进制搜索以找到最小元素.
让我们假设初始列表是{1,2,3,4,5,6,7,8},旋转列表可以像{5,6,7,8,1,2,3,4}
在这种情况下,正常的二进制搜索不起作用.知道如何做到这一点.
- 编辑
我有另一个条件.如果列表没有排序怎么办?
c++ java algorithm binary-search data-structures
algorithm ×1
binary-search ×1
c++ ×1
data-structures ×1
java ×1