Binary vs Linear searches for unsorted N elements

前端 未结 5 901
予麋鹿
予麋鹿 2021-01-19 00:44

I try to understand a formula when we should use quicksort. For instance, we have an array with N = 1_000_000 elements. If we will search only once, we sho

5条回答
  •  不思量自难忘°
    2021-01-19 00:50

    You want to solve inequality that rougly might be described as

    t * n > C * n * log(n) + t * log(n)
    

    where t is number of checks and C is some constant for sort implementation (should be determined experimentally). When you evaluate this constant, you can solve inequality numerically (with uncertainty, of course)

提交回复
热议问题