Algorithms and Big O, How to classify them.
Starting to learn Algorithms can be very difficult and hard to understand.
First we need to know what is a an Algorithm is. In simple words its a series of contained steps, which are followed in order to achieve a set goal, or to produce an output. For example any cooking recipe has steps to be followed to achieve the correct meal, this makes it count as an algorithm, crazy right?!
function BakeBrownies(flavor, chocolateChips){
"
1. Heat Oven to 350 F
2. Mix flour, cocoa, salt
3. Melt butter and chocolate until fully mixed
4. Mix in flour, baking cocoa, salt, eggs and sugar
5. Add chocolate, butter and " + flavor + "
6. Mix further
7. Put in greased pan
8. Bake for 30 minutes
9." + if(chocolateChips === true) return 'add chocolateChips' + "
10. Feast them brownies
"
}
BakeBrownies('muchChocolate', true) => tasty
So, What is Big O notation?
It is a very abstract and esoteric concept that most people will never hear about, or care about. But it is known as being a common coding interview question, and therefore it’s one of the things I have spent most of my time trying to understand and get good at them.