Equivalence testing of n objects

前端 未结 4 1232
一向
一向 2021-01-07 05:20

Assume that we are given \'n\' objects and a subroutine that takes two inputs and says if they are equivalent or not (e.g. it can give output as 1 if they are equal).

<
4条回答
  •  一向
    一向 (楼主)
    2021-01-07 05:38

    Considering that the sequence is ordered you can use binary search, which takes O(log n), and since you'll have to do it for every element, and you have n elements it will take O(n*log n).

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题