Just a few algorithms with explanations in the comments.