根据字符串长度对已排序的字符串复杂度数组进行二进制搜索
Binary search on sorted array of strings complexity in terms of string length
对于大小为 n 的已排序字符串数组,二进制搜索将采用 n 的 O(log n)。但是,就字符串长度而言,运行 时间是多少?
字符串比较的复杂度是字符串长度的线性时间,因此,在这种情况下,让 m = string length
,复杂度为
O(m lg n)
。
对于大小为 n 的已排序字符串数组,二进制搜索将采用 n 的 O(log n)。但是,就字符串长度而言,运行 时间是多少?
字符串比较的复杂度是字符串长度的线性时间,因此,在这种情况下,让 m = string length
,复杂度为
O(m lg n)
。