Random Visual Mnemonics for Programming - part 2
Bit operations visual mnemonics:
| Operation |
Calculation |
Mnemonic |
| GET bit i |
n&(1<<i) |
nacicci (拿 ná) |
| SET bit i |
n|(1<<i) |
nicicci ("knee") |
| CLR bit i |
n&~(1<<i) |
nancicci ("none") |
| CLR (MSB to bit i) |
n&((1<<i)-1) |
nacciccimi |
| CLR (bit i to LSB) |
n&(-1<<(i+1)) |
nacmiccipi |
| UPDATE bit i |
n&~(1<<i) | (1<<i) |
nancicci icicci |
BFS visual mnemonic:
Translation: To go through each level of a tree at a time, queue the most immediate child nodes and then look at each of their child nodes.
Heap visual mnemonic:
Translation: To add to a heap, add to last position, then bubble-up. To remove the top/head node from the heap, remove it, then move the node in the last position ot the top, and then bubble-down.
More visual mnemonics: here.