Click here to Skip to main content
15,885,278 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Calculate time complexity step by step of given two program program Pin
Gerry Schmitz24-Sep-20 13:01
mveGerry Schmitz24-Sep-20 13:01 
QuestionRandom File & Folder Names Pin
Richard Andrew x6422-Sep-20 10:42
professionalRichard Andrew x6422-Sep-20 10:42 
AnswerRe: Random File & Folder Names Pin
Victor Nijegorodov22-Sep-20 10:56
Victor Nijegorodov22-Sep-20 10:56 
GeneralRe: Random File & Folder Names Pin
Richard Andrew x6422-Sep-20 11:06
professionalRichard Andrew x6422-Sep-20 11:06 
QuestionHow can I calculate time complexity and compare between given two algorithms? Pin
Member 1151248618-Sep-20 18:12
Member 1151248618-Sep-20 18:12 
QuestionRe: How can I calculate time complexity and compare between given two algorithms? Pin
Richard MacCutchan18-Sep-20 21:42
mveRichard MacCutchan18-Sep-20 21:42 
AnswerRe: How can I calculate time complexity and compare between given two algorithms? Pin
Member 1151248619-Sep-20 0:45
Member 1151248619-Sep-20 0:45 
AnswerRe: How can I calculate time complexity and compare between given two algorithms? Pin
trønderen19-Sep-20 2:43
trønderen19-Sep-20 2:43 
Benchmarking is not to determine algorithmic complexity.

It can be used to confirm that your theoretically determined O() is correct, but a few timing values is not an O().

To the OP: In my studies, algorithmic complexity was the sole subject of a quarter-long course. The textbook was a few hundred pages long. I don't remember if I took it during our junior or senior year; in any case, we were quite experienced programmers then, and had completed courses in related subjects like statistics and queue theory. The foundation was in place.

If you want to learn how to determine the algorithmic complexity in general, you may have a long path to walk. There may be quick and easy answers to specific, simple, algorithms (an experienced guy can pop an O() right out of his head for the examples you present), but you would benefit from learning more general methods for complexity estimation.

And: If you are doing timing benchmarks, make sure to test over a broad range of input - here: in terms of problem size. With small problem sets, initial setup, reporting etc. can make up a large part of the time consumed. Also, be very much aware of compiler optimizations. Some compilers are clever shortcutting loops etc. in a way that may severely affect timings. It may be safer to turn all optimization off. (Actually, for verifying a theoretical O(), you might come better out by adding counters to your code in appropriate places, rather than measuring execution times!)
GeneralRe: How can I calculate time complexity and compare between given two algorithms? Pin
Richard MacCutchan19-Sep-20 3:01
mveRichard MacCutchan19-Sep-20 3:01 
GeneralRe: How can I calculate time complexity and compare between given two algorithms? Pin
trønderen19-Sep-20 7:06
trønderen19-Sep-20 7:06 
GeneralRe: How can I calculate time complexity and compare between given two algorithms? Pin
Richard MacCutchan19-Sep-20 21:05
mveRichard MacCutchan19-Sep-20 21:05 
AnswerRe: How can I calculate time complexity and compare between given two algorithms? Pin
Sandeep Mewara19-Sep-20 0:12
mveSandeep Mewara19-Sep-20 0:12 
GeneralRe: How can I calculate time complexity and compare between given two algorithms? Pin
Member 1151248619-Sep-20 0:55
Member 1151248619-Sep-20 0:55 
GeneralRe: How can I calculate time complexity and compare between given two algorithms? Pin
Gerry Schmitz19-Sep-20 3:00
mveGerry Schmitz19-Sep-20 3:00 
GeneralRe: How can I calculate time complexity and compare between given two algorithms? Pin
trønderen19-Sep-20 7:03
trønderen19-Sep-20 7:03 
GeneralRe: How can I calculate time complexity and compare between given two algorithms? Pin
Gerry Schmitz20-Sep-20 4:52
mveGerry Schmitz20-Sep-20 4:52 
QuestionMy implementation of Eratosthenes sieve is horribly slow. But why? Pin
Member 149328737-Sep-20 22:00
Member 149328737-Sep-20 22:00 
AnswerRe: My implementation of Eratosthenes sieve is horribly slow. But why? Pin
Richard MacCutchan7-Sep-20 22:38
mveRichard MacCutchan7-Sep-20 22:38 
GeneralRe: My implementation of Eratosthenes sieve is horribly slow. But why? Pin
Richard Deeming7-Sep-20 23:59
mveRichard Deeming7-Sep-20 23:59 
AnswerRe: My implementation of Eratosthenes sieve is horribly slow. But why? Pin
Dave Kreskowiak8-Sep-20 6:46
mveDave Kreskowiak8-Sep-20 6:46 
GeneralRe: My implementation of Eratosthenes sieve is horribly slow. But why? Pin
Richard Andrew x6422-Sep-20 10:36
professionalRichard Andrew x6422-Sep-20 10:36 
GeneralRe: My implementation of Eratosthenes sieve is horribly slow. But why? Pin
Dave Kreskowiak22-Sep-20 16:25
mveDave Kreskowiak22-Sep-20 16:25 
AnswerRe: My implementation of Eratosthenes sieve is horribly slow. But why? Pin
Patrice T18-Sep-20 19:51
mvePatrice T18-Sep-20 19:51 
QuestionHow can I remove alternate words from a sentence? Pin
maicart5-Sep-20 22:27
maicart5-Sep-20 22:27 
AnswerRe: How can I remove alternate words from a sentence? Pin
Gerry Schmitz6-Sep-20 4:14
mveGerry Schmitz6-Sep-20 4:14 

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.