Skip to main content

Posts

This blog is kept live for posterity -- you can visit my new website at www.samjgriffiths.co.uk.

Featured

Optimisation Techniques

In this post: I outline a variety of commonly-used, simple approaches for optimising algorithms. Useful background: None in particular! Discovering and implementing efficient algorithms is often nowhere near an easy task; however, more novel ways to improve overall efficiency of computation, such as through heuristic/probabilistic approaches and shortcuts in code, can be employed quite easily to great effect, often in a tradeoff with other resources. Let's look at a handful of commonly-used tricks to improve average efficiency: Tail recursion Memoisation Self-organising lists Sentinel values Approximate computing Tail recursion Consider some arbitrary function that takes a form like this: int f ( int x) { //do stuff, culminating in: return g(x); } What's going on with the call stack when we call f() from, say, main() ? main() transfers control to f() , which in turn transfers control to g() . g() then transfers control back to f() , which

Latest posts

Sparse Sets

Using Templates