What is a 51% attack and how to detect it?

Despite the inordinate amount of resources needed to engineer them, small-cap cryptocurrencies are still susceptible to a 51% attacks.