Algorithm-finding kth next element in an array

后端 未结 3 1764
别那么骄傲
别那么骄傲 2021-01-20 14:30

I couldn\'t solve a question can you please help?

For i=1 to i=n/2, if A[i]<=A[2i] and A[i]<=A[2i+1] A is called as a \"bst\" 

What\

3条回答
  •  青春惊慌失措
    2021-01-20 14:52

    There are two methods:

    1. O(k ln(n)) time complexity.
    2. O(k ln(k)) time complexity + O(K) space complexity.

提交回复
热议问题