Click here to Skip to main content
15,898,975 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Algorithm Sum From Offset To Number Pin
dusty_dex17-Jun-13 23:03
dusty_dex17-Jun-13 23:03 
GeneralRe: Algorithm Sum From Offset To Number[Edited] Pin
A*****18-Jun-13 12:50
A*****18-Jun-13 12:50 
GeneralRe: Algorithm Sum From Offset To Number[Edited] Pin
dusty_dex18-Jun-13 13:20
dusty_dex18-Jun-13 13:20 
GeneralRe: Algorithm Sum From Offset To Number[Edited] Pin
A*****18-Jun-13 13:24
A*****18-Jun-13 13:24 
AnswerRe: Algorithm Sum From Offset To Number Pin
Bernhard Hiller18-Jun-13 20:57
Bernhard Hiller18-Jun-13 20:57 
GeneralRe: Algorithm Sum From Offset To Number Pin
dusty_dex18-Jun-13 22:38
dusty_dex18-Jun-13 22:38 
QuestionWikipedia's comments on Interpolation Search Pin
harold aptroot11-Jun-13 0:59
harold aptroot11-Jun-13 0:59 
AnswerRe: Wikipedia's comments on Interpolation Search Pin
Alan Balkany13-Jun-13 8:27
Alan Balkany13-Jun-13 8:27 
It seems like the interpolation search does more work per iteration, so you could do more binary search iterations in the same time.

The extra work is done in the calculation of mid:

JavaScript
mid = low +
      ((toFind - sortedArray[low]) * (high - low)) /
      (sortedArray[high] - sortedArray[low]);  //out of range is possible.


while the binary search is leaner: http://en.wikipedia.org/wiki/Binary_search[^]

It looks like the calculation of mid requires on the order of ten extra instructions per iteration. And one of these is a division, which is relatively slower. Using the same array element a second time won't take twice the time because the value will be stored in the cache the first time.

One factor that may slow down the binary search is the recursive call at each iteration, although it could be written iteratively.

So the Wikipedia claim could be correct.

But the number of iterations needed for the interpolation search is dependent on how uniform the distribution of numbers is. For a near-uniform distribution, you'd only need one iteration of interpolation search.
GeneralRe: Wikipedia's comments on Interpolation Search Pin
harold aptroot13-Jun-13 8:59
harold aptroot13-Jun-13 8:59 
Questionalgorithm that finds the m smallest numbers in a list of numbers Pin
demo 29-Jun-13 21:00
demo 29-Jun-13 21:00 
AnswerRe: algorithm that finds the m smallest numbers in a list of numbers Pin
Richard MacCutchan9-Jun-13 21:14
mveRichard MacCutchan9-Jun-13 21:14 
GeneralRe: algorithm that finds the m smallest numbers in a list of numbers Pin
demo 29-Jun-13 23:50
demo 29-Jun-13 23:50 
GeneralRe: algorithm that finds the m smallest numbers in a list of numbers Pin
Richard MacCutchan9-Jun-13 23:53
mveRichard MacCutchan9-Jun-13 23:53 
GeneralRe: algorithm that finds the m smallest numbers in a list of numbers Pin
demo 210-Jun-13 0:07
demo 210-Jun-13 0:07 
GeneralRe: algorithm that finds the m smallest numbers in a list of numbers Pin
Richard MacCutchan10-Jun-13 0:13
mveRichard MacCutchan10-Jun-13 0:13 
GeneralRe: algorithm that finds the m smallest numbers in a list of numbers Pin
demo 210-Jun-13 0:24
demo 210-Jun-13 0:24 
GeneralRe: algorithm that finds the m smallest numbers in a list of numbers Pin
Richard MacCutchan10-Jun-13 0:31
mveRichard MacCutchan10-Jun-13 0:31 
GeneralRe: algorithm that finds the m smallest numbers in a list of numbers Pin
demo 210-Jun-13 10:13
demo 210-Jun-13 10:13 
GeneralRe: algorithm that finds the m smallest numbers in a list of numbers Pin
Richard MacCutchan10-Jun-13 20:38
mveRichard MacCutchan10-Jun-13 20:38 
GeneralRe: algorithm that finds the m smallest numbers in a list of numbers Pin
demo 210-Jun-13 21:57
demo 210-Jun-13 21:57 
GeneralRe: algorithm that finds the m smallest numbers in a list of numbers Pin
Richard MacCutchan10-Jun-13 23:05
mveRichard MacCutchan10-Jun-13 23:05 
GeneralRe: algorithm that finds the m smallest numbers in a list of numbers Pin
demo 211-Jun-13 12:33
demo 211-Jun-13 12:33 
GeneralRe: algorithm that finds the m smallest numbers in a list of numbers Pin
Richard MacCutchan11-Jun-13 21:08
mveRichard MacCutchan11-Jun-13 21:08 
GeneralRe: algorithm that finds the m smallest numbers in a list of numbers Pin
Amarnath S11-Jun-13 17:38
professionalAmarnath S11-Jun-13 17:38 
AnswerRe: algorithm that finds the m smallest numbers in a list of numbers Pin
Usman Khalid Butt29-Jun-13 3:24
Usman Khalid Butt29-Jun-13 3:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.