Efficient way to write complicated algorithms

My problem is that I make mistakes writing code. For a simple function these mistakes pop out in a dramatic way usually, so I can fix them and move on. On a more complicated program this is not the case and eventually I give up. Sometimes I don't manage to fix all the mistakes and only know it because the produced result is wrong.

For more complicated things I usually break it up into small chunk and and verify the correctness chunk by chunk. How do I this if there is no linear path of breaking things up or if that is just too time consuming?

Topic programming

Category Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.