Profile
Achievement
 
                     
    
                rtperson's Recent Snippets
- All /
 « Prev 1 Next »
Really DP-lite. Memoize the solution for a recursive problem so it can be looked up on subsequent iterations.
        
        
        
            0 
        
        
            2429 
        
                    posted 12 years ago by rtperson
            You have to use float or double for the returned value, since the scale occurs in a continuous function.
        
        
        
            0 
        
        
            2223 
        
                    posted 13 years ago by rtperson
            It's no fun implementing QuickSort unless you can force it out of its blister-fast, O(n log n) speed and humiliate it with its worst-case, O(n^2) runtime. So that's what I set out to do.  
My naive partition simply pivots around the low item, but...
        
        
        
            0 
        
        
            1248 
        
                    posted 13 years ago by rtperson
            Two versions of binary search -- one recursive, one iterative -- for an array of strings.
Both assume that your array index fits within an integer.
        
        
        
            0 
        
        
            1467 
        
                    posted 13 years ago by rtperson
            Check that a given integer consists only of elements of a given set. It does a linear search through the set, so the assumption is that the set to search is relatively small. If you're chewing through a particularly large set of digits, you may want...
        
        
        
            0 
        
        
            3373 
        
                    posted 14 years ago by rtperson