Divison of a range

If i have a range of numbers from min- max is there any predefined implementation to find the sub ranges of the existing range.e.g. If the range is 0-10 the sub ranges could be 0-2, 3-5,etc If not which algorithm would be useful?
[243 byte] By [Prameelaa] at [2007-10-1 18:29:38]
# 1

2 options came to mind:

1. scan the entire array. Check each element is greater than smin and less than smax. Add element to secondary array / list / vector.

2. sort the array. Perform binary search to find the first index location occurrence of smin. Do the same for smax. Return the index locations.

You might want to create 2 binary search methods:

findFirstOccurrence(int x, int[] arr)

findLastOccurrence(int x, int[] arr)

rkippena at 2007-7-11 13:25:32 > top of Java-index,Other Topics,Algorithms...