In a sorted and rotated array, one subarray is always sorted and one is always disturbed. So does the pivot element always lie in the disturbed half of the array?
Doubt regarding presence of pivot element in a sorted rotated array
Both Subarrays (start…pivot_index) and (pivot_index+1 to end) are sorted.
Okay I got your point. Thank you Sir.
Hello @Ibrahim,
It will be part of the non-sorted part.
Example:
4 5 6 1 2 3
a… for two halves:
4 5 and 6 1 2 3
6 being the pivot element will be part of the non-sorted part.
b… for two halves:
4 5 6 and 1 2 3
It is part of the sorted array and this is the only case when it is the part of the sorted array.
BTW, you have re-opened this doubts.
Do, you have something to ask?
Thank you for your answer sir. And I didn’t reopen this doubt, I tried to mark it resolved on the phone but somehow it had some problem and it kept getting marked as reopen.