Bitcoin's method is detailed in Satoshi's classic paper:
https://bitcoin.org/bitcoin.pdf
Ethereum uses a variant of the GHOST algorithm, which was introduced in the paper Accelerating Bitcoin’s Transaction Processing: Fast Money Grows on Trees, Not Chains.
https://eprint.iacr.org/2013/881.pdf
The Ethereum white paper mentions how they modified it:
https://github.com/ethereum/wiki/wiki/White-Paper#modified-g...
Full detail is in their infamously difficult Yellow Paper: