@Lucifier :

for the else case;

suppose arr is 6,10,8,5,9,7,1,5,4,3    K=8

at max =10 , min =1 condition will fail

A[j] = A[Top(minH)];

currentStrInd = Top(MaxH) +1; // currentStrInd = index of 8
pop(Top(MaxH));

now because of A[Top(MaxH)] - A[Top(MinH)] <= K (9 -1= 8)condition in while
loop

while loop will break.

so now maxH and MinH has value 6 , which is not required. so may be on
further calculation if we keep on finding new A[j] which would violate the
difference condition.
at some point of time minH will be 6 but it is not the part of the
calculation bcozz i apprears only once i.e at A[0].

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

Reply via email to