Results for “Small algorithms & bit operations”
Small, practical examples. Search by task or narrow things down below.
Read the smallest and largest values
SQL Server: Use MIN and MAX without sorting and fetching every row.
SQL Server✓ Tested
Read the smallest and largest values
Postgres: Use MIN and MAX without sorting and fetching every row.
Postgres✓ Tested
Read the smallest and largest values
SQLite: Use MIN and MAX without sorting and fetching every row.
SQLite✓ Tested
Represent a small set of named states
C: An enum gives symbolic names to integer state values.
C✓ Tested
Require every bit in a mask
Arduino / C: Masking followed by equality tests whether all required flags are set.
Arduino / C✓ Tested
Return a small immutable named record
Python: Use NamedTuple when callers need both tuple behavior and named fields.
Python✓ Tested
Search a small FTS5 table
Use SQLite’s full-text index to match a term.
FTS5✓ Tested
Serialize a 16-bit integer in big-endian order
C: Explicit shifts make a byte format independent of the CPU’s native byte order.
C✓ Tested
Set and inspect a bit flag
Store several boolean states in one byte.
bitSet✓ Tested
Set and test bit flags
Use unsigned masks to combine and test C flags.
C✓ Tested
Sort a small array in place
Arduino / C: Insertion sort needs no additional array and is suitable for small datasets.
Arduino / C✓ Tested
Sort a small set of lines
Linux Commands: Sort a small set of lines using GNU/Linux commands in an empty practice directory.
Linux Commands✓ Tested