Computer Science, asked by karan5445, 11 months ago

If a sorted array is rotated by k positions, what is the time complexity to find the starting point of the original array?

Answers

Answered by ThelaughterQueen
0

Explanation:

Entity relationship modeling is dependent on the hardware or software used for implementation, so you will need to change your erd if you decide to change hardware vendor. True or false? Mark for review (1) points true false

Answered by qwwestham
0

If a sorted array is rotated by k positions, the time complexity to find the starting point of the original array is O( log( N)).

The result still works out to a double hunt in the sense that you will need to partition the array into two corridor to be examined.

  • In a sorted array, you just look at each part and determine whether the element lives in the first part( let's call this A) or the alternate part( B).
  • Since, by the description of a sorted array, partitions A and B will be sorted, this requires no further than some simple comparisons of the partition bounds and your hunt key.
  • In a rotated sorted array, only one of A and B can be guaranteed to be sorted.
  • However, also the result is simple just perform the hunt as if you were doing a normal double hunt, If the element lies within a part which is sorted.
  • However, still, you must search an unsorted part.
  • Reduced to the problem of chancing the largest number position, which can be done by checking the first and last and middle number of the area, recursively reduce the area, divide and conquer, This is O( log( N)) no larger than the double hunt O( log( N)).

Hence , this gives on a time complexity of O( lg n).

#SPJ3

Similar questions