Click here to Skip to main content
15,914,413 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Bignum timing Pin
PIEBALDconsult12-Dec-14 17:12
mvePIEBALDconsult12-Dec-14 17:12 
GeneralRe: Bignum timing Pin
Member 419459313-Dec-14 7:13
Member 419459313-Dec-14 7:13 
GeneralRe: Bignum timing Pin
Member 419459314-Jan-15 11:20
Member 419459314-Jan-15 11:20 
GeneralRe: Bignum timing Pin
PIEBALDconsult14-Jan-15 12:40
mvePIEBALDconsult14-Jan-15 12:40 
GeneralRe: Bignum timing Pin
Member 419459314-Jan-15 14:47
Member 419459314-Jan-15 14:47 
Questionsimple maby for you Pin
Member 1130547811-Dec-14 23:00
Member 1130547811-Dec-14 23:00 
SuggestionRe: simple maby for you Pin
ZurdoDev12-Dec-14 4:14
professionalZurdoDev12-Dec-14 4:14 
QuestionI'm looking for an algorithm ... Pin
filos14-Dec-14 1:45
filos14-Dec-14 1:45 
AnswerRe: I'm looking for an algorithm ... Pin
Patrice T22-Jun-15 9:36
mvePatrice T22-Jun-15 9:36 
QuestionRandomizing Flickr Tags Based on Search Term Pin
Member 1051454915-Nov-14 1:15
Member 1051454915-Nov-14 1:15 
QuestionAlgorithm to count how many "1" in binary o(1) Pin
Member 1105509311-Nov-14 2:13
Member 1105509311-Nov-14 2:13 
AnswerRe: Algorithm to count how many "1" in binary o(1) PinPopular
Kornfeld Eliyahu Peter11-Nov-14 2:33
professionalKornfeld Eliyahu Peter11-Nov-14 2:33 
GeneralRe: Algorithm to count how many "1" in binary o(1) Pin
Member 1105509312-Nov-14 1:07
Member 1105509312-Nov-14 1:07 
AnswerRe: Algorithm to count how many "1" in binary o(1) Pin
Richard Deeming11-Nov-14 2:39
mveRichard Deeming11-Nov-14 2:39 
SuggestionRe: Algorithm to count how many "1" in binary o(1) Pin
Kornfeld Eliyahu Peter11-Nov-14 2:43
professionalKornfeld Eliyahu Peter11-Nov-14 2:43 
GeneralRe: Algorithm to count how many "1" in binary o(1) Pin
harold aptroot12-Nov-14 9:36
harold aptroot12-Nov-14 9:36 
AnswerRe: Algorithm to count how many "1" in binary o(1) Pin
Aurimas11-Nov-14 3:27
Aurimas11-Nov-14 3:27 
AnswerRe: Algorithm to count how many "1" in binary o(1) Pin
Joe DiNatale12-Nov-14 8:17
Joe DiNatale12-Nov-14 8:17 
AnswerRe: Algorithm to count how many "1" in binary o(1) Pin
harold aptroot12-Nov-14 10:04
harold aptroot12-Nov-14 10:04 
It depends on your abstract model. With the usual model, you can't do any better than O(n) (so o(n) is not happening, or did you write a lower case o by accident?) - obviously on a plain old Turing machine, you're going to have to read every bit.

But this problem is in NC. You could sum n/2 pairs of bits, then n/4 pairs of "2bit numbers", n/8 pairs of nibbles, etc, and you're done in log n steps, with each step taking logarithmic time too (adders) (sometimes not counted), all with a polynomial number of processing elements.

Similarly in "broadword computing", you would say that you could compute this in O(log n) broadword steps - using the same construction, but now every layer is a couple of steps (mask and add) (with the addition counted as 1 step, instead of as a circuit of depth O(log n))

Practically, on 32bit words but "pretending 32 is not a constant", you can still use the same construction for an O(log n) algorithm possibly with a multiplication trick to do several sums at once (already shown in answers) or lookup tables or (with as much space as you need, you could cheat terribly and compute any mapping from 32bit integers to anything in a single step), if available, the popcnt instruction.
For arrays you could use a pshufb-based trick[^] (pshufb is awesome).
QuestionPYTHON X-AXIS NEAREST POINT Pin
Member 112001292-Nov-14 6:01
Member 112001292-Nov-14 6:01 
AnswerRe: PYTHON X-AXIS NEAREST POINT Pin
Richard MacCutchan2-Nov-14 6:45
mveRichard MacCutchan2-Nov-14 6:45 
GeneralRe: PYTHON X-AXIS NEAREST POINT Pin
Member 112001292-Nov-14 7:14
Member 112001292-Nov-14 7:14 
GeneralRe: PYTHON X-AXIS NEAREST POINT Pin
Richard MacCutchan2-Nov-14 7:24
mveRichard MacCutchan2-Nov-14 7:24 
GeneralRe: PYTHON X-AXIS NEAREST POINT Pin
Albert Holguin5-Nov-14 10:43
professionalAlbert Holguin5-Nov-14 10:43 
GeneralRe: PYTHON X-AXIS NEAREST POINT Pin
CHill602-Nov-14 10:33
mveCHill602-Nov-14 10:33 

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.