What is the algorithm that adjusts the difficulty of the proof of works in a proof of work based cryptocurrency?
The difficulty is a function of block creation speed.
The goal is to, on average, create blocks every 10 mins. 
It is recalculated every two weeks (link)
You can look up the calculation of difficulty in the open source code of Bitcoin
https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49