Efficient algorithm to find a the set of numbers in a range
        Posted  
        
            by 
                user133020
            
        on Programmers
        
        See other posts from Programmers
        
            or by user133020
        
        
        
        Published on 2014-05-30T13:25:10Z
        Indexed on 
            2014/05/30
            15:58 UTC
        
        
        Read the original article
        Hit count: 218
        
If I have an array of sorted numbers and every object is one of the numbers or multiplication. For example if the sorted array is [1, 2, 7] then the set is {1, 2, 7, 1*2, 1*7, 2*7, 1*2*7}. As you can see if there's n numbers in the sorted array, the size of the set is 2n-1.
My question is how can I find for a given sorted array of n numbers all the objects in the set so that the objects is in a given interval. For example if the sorted array is [1, 2, 3 ... 19, 20] what is the most efficient algorithm to find the objects that are larger than 1000 and less than 2500 (without calculating all the 2n-1 objects)? 
© Programmers or respective owner