# Which calculating running time are correct?

Let $$C$$ be an array with length $$n$$ (assume the elements are cities with some properties). We have some properties sorted by importance. For example, 1.area, 2.population size, .... We use the following algorithm to find the best city according to sorted properties:

We choose the first property and examine each city. Then we delete half of the cities. (assume we can do this by $$O(n)$$ time.) Now we apply the second properties and again delete half of the remain cities. We continue this way until one city remains.

Can we say the running time is equal to $$O(n)$$ according to the recursive function $$T(n)= T(n/2)+ O(n)$$, and the master theorem or the running time is equal to $$n \log(n)$$ because we use binary search and in each iteration, we apply an operator in linear time?

which is correct and why another one is incorrect?

• Where are you using binary search? – gnasher729 Oct 26 '18 at 20:13

The $$T(n)= 2 T(n/2)+O(n)$$ is $$\mathcal{O}(n \log(n))$$
Your recursion $$T(n)=T(n/2)+O(n)$$ is $$\mathcal{O}(n)$$ by The 3rd case of The Master Theorem.
• Does the recursion function $T(n)= T(n/2)+O(n)$ correct for the mentioned algorithm? – A.R.S Oct 26 '18 at 10:50
• Yes, it is correct. put $cn$ instead of $\mathcal{O}(n)$ and see by recursion tree, actually vine(backbone). – kelalaka Oct 26 '18 at 10:53