Hey all,
I was wondering if anybody knew some good sites about the basic concept of algorithm efficiency? If you do, would you kindly post them? Thank you.
This is a discussion on Algorithm Efficiency within the C++ Programming forums, part of the General Programming Boards category; Hey all, I was wondering if anybody knew some good sites about the basic concept of algorithm efficiency? If you ...
Hey all,
I was wondering if anybody knew some good sites about the basic concept of algorithm efficiency? If you do, would you kindly post them? Thank you.
The concept is well known. It is often referred to as "common sense"I was wondering if anybody knew some good sites about the basic concept of algorithm efficiency?
Seriously, though, it's just a matter of:
- refining your code so that it cannot be reduced any further.
- never calling a function twice if you don't need to.
- using a few variables as necessary. Care should be taken here, though as to not make your code hard to read, of course...just use common sense.
-weigh the impact of speed on a choice of an algorithm, and it's relative importance.
-align variables in classes and structs such to minimize padding.
In general, if you are aiming for lightning speed, (and I mean where it is necessary, and not just a frivolous desire), then you can comprimise readability to maximize the above.
Code:#include <cmath> #include <complex> bool flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0)*(1 << (value + 2))) ).real() < 0; }
It depends on what your coding. It's best
not to limit yourself to efficiancy but also correctness.
This has the best online resourses. A few authors have
put up their lecture notes but your best off getting a book.
http://www.math.gatech.edu/~cain/tex...linebooks.html