Naming ¶
- use memorable variable names: we have limited working memory
- how to find good variable names: describe what it does with a sentence and picking its 2-3 most important words. -> not too long
- array names have to describe what they contain
- be consistent
Reformulate ¶
Une question bien posée est une question a moitié résolue
- we have the ... (data we have)
- we're asked to ... (data we have to find)
- we have to strip the fluff and keep
- the description of the information we have
- the description of the question
- the names and objects that help us find our way with the input data
- any detail that impacts the algorithm
- also reformulate sub-problems
How to find algorithm ideas ¶
- read the subject well and reformulate
- list the constraints
- find a good graphic representation
- solve examples by hand
- find a slow algorithm and then optimize it
- renew perspective:
- enumerate algorithm types to see if they're applicable
- find other representations
- enumerate the main loops / methods of traversal
- important: simplify the problem; then generalize the solution