Click here to Skip to main content
15,892,005 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Can someone please help me optimize(decrease time complexity) this algorithm.. Pin
Richard MacCutchan18-May-18 5:59
mveRichard MacCutchan18-May-18 5:59 
QuestionAlgorithm for golf putting. Slope 1-4 degrees Pin
Member 1375000827-Mar-18 11:06
Member 1375000827-Mar-18 11:06 
AnswerRe: Algorithm for golf putting. Slope 1-4 degrees Pin
Gerry Schmitz2-Apr-18 6:01
mveGerry Schmitz2-Apr-18 6:01 
Questionrecursive algorithm Pin
Member 1374335523-Mar-18 7:00
Member 1374335523-Mar-18 7:00 
AnswerRe: recursive algorithm Pin
Gerry Schmitz23-Mar-18 12:00
mveGerry Schmitz23-Mar-18 12:00 
AnswerRe: recursive algorithm Pin
Peter_in_278023-Mar-18 14:53
professionalPeter_in_278023-Mar-18 14:53 
QuestionSquare root of positive integer using binary search. Pin
lnikon25-Feb-18 9:40
lnikon25-Feb-18 9:40 
GeneralRe: Square root of positive integer using binary search. Pin
harold aptroot25-Feb-18 10:29
harold aptroot25-Feb-18 10:29 
Why recursion? Binary search can be expressed as iteration, or, since you actually have a constant bound on the number of iterations here, an unrolled iteration. That would IMO still count as the same algorithm, just a different realization of it.
lnikon wrote:
left + (right - left) / 2
This trick is to avoid overflow. There cannot be any overflow here anyway, since both left and right will be well below MAXINT (at most they'll be the square root of MAXINT). So you can write it the simple/shorter/faster way.
lnikon wrote:
middle == 0 && middle <= x / (middle + 1)
Is this even correct? Note that the right operand of the && effectively checks whether 0 <= x which is not useful since x is known to be non-negative (pre-condition).
The whole zero business can be avoided by checking whether middle * middle > x (this multiplication cannot overflow unless incorrect bounds were passed), which by avoiding division is both "zero-safe" and more efficient.
GeneralRe: Square root of positive integer using binary search. Pin
lnikon25-Feb-18 10:54
lnikon25-Feb-18 10:54 
AnswerRe: Square root of positive integer using binary search. Pin
Richard Deeming26-Feb-18 1:21
mveRichard Deeming26-Feb-18 1:21 
AnswerRe: Square root of positive integer using binary search. Pin
Patrice T7-Apr-18 21:01
mvePatrice T7-Apr-18 21:01 
Question3D Points to 2D Points Pin
Member 1368222216-Feb-18 15:34
Member 1368222216-Feb-18 15:34 
AnswerRe: 3D Points to 2D Points Pin
Ralf Meier17-Feb-18 0:35
mveRalf Meier17-Feb-18 0:35 
GeneralRe: 3D Points to 2D Points Pin
jschell17-Feb-18 11:41
jschell17-Feb-18 11:41 
GeneralRe: 3D Points to 2D Points Pin
Ralf Meier17-Feb-18 23:02
mveRalf Meier17-Feb-18 23:02 
QuestionNode discovery in a truly decentralized system Pin
stopthespying15-Feb-18 6:40
stopthespying15-Feb-18 6:40 
AnswerRe: Node discovery in a truly decentralized system Pin
Gerry Schmitz16-Feb-18 5:21
mveGerry Schmitz16-Feb-18 5:21 
QuestionFinding strongly connected component in a directed Graph using PHP Pin
Member 136573131-Feb-18 21:22
Member 136573131-Feb-18 21:22 
QuestionA very interesting question for you all Pin
Member 1364484725-Jan-18 14:28
Member 1364484725-Jan-18 14:28 
AnswerRe: A very interesting question for you all Pin
Richard MacCutchan25-Jan-18 22:26
mveRichard MacCutchan25-Jan-18 22:26 
AnswerRe: A very interesting question for you all Pin
jschell8-Feb-18 13:33
jschell8-Feb-18 13:33 
AnswerRe: A very interesting question for you all Pin
Luc Pattyn8-Feb-18 14:59
sitebuilderLuc Pattyn8-Feb-18 14:59 
Questionpython code on Effect of order of accuracy on the numerical differentiation Pin
Member 1362564316-Jan-18 1:32
Member 1362564316-Jan-18 1:32 
GeneralRe: python code on Effect of order of accuracy on the numerical differentiation Pin
harold aptroot17-Jan-18 23:28
harold aptroot17-Jan-18 23:28 
QuestionCompare products in Cart against min/max limitations Pin
Rico6419-Dec-17 7:07
Rico6419-Dec-17 7:07 

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.