@Bhupendra

Thanks for pointing it out

actually, it should be
3.now first element in A[0]..A[j-1] greater than min is 7(index 1) and *LAST
* element in
   A[k+1]....A[n] less than max is 1(index 9)


if you look at code, it was proper
for( i = e+1; i < n; i++)
  {
    if(arr[i] < max)
      e = i;
  }



PS: min and max are 5 and 17


A guy called lovocas asked same question in forum


Mohit



On Mon, Dec 20, 2010 at 7:43 PM, bhupendra dubey <bhupendra....@gmail.com>wrote:

> @mohit
> suppose the input array is {4,7,8,6,5,11,13,17,0,1,2,3}
>
> 1.first step of Ur algorithm gives j=2,k=9  (index of 8 and 1)
> 2.in the second step min and max comes out to be 5 and 13
> 3.now first element in A[0]..A[j-1] greater than min is 7(index 1) and
> first element in
>    A[k+1]....A[n] less than max is 1(index 9)
>
> so final answer accordingly is A[1]..A[9]
>
> but clearly for the given input it shud be the whole array itself not
> any sub-array
> please clarify if iam wrong
>
>
> Thanx
>
> On Mon, Dec 20, 2010 at 10:45 AM, awesomeandroid <
> priyaranjan....@gmail.com> wrote:
>
>> i have posted this problem along with solution to my blog check :
>>
>> http://code-forum.blogspot.com/2010/12/find-minimum-length-unsorted-subarray.html
>>
>> On Dec 18, 10:57 pm, snehal jain <learner....@gmail.com> wrote:
>> > Given an unsorted array arr[0..n-1] of size n, find the minimum length
>> > subarray arr[s..e] such that sorting this subarray makes the whole
>> > array sorted.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> bhupendra dubey
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to