Learning Algorithms and Optimization for Beginners

Learn why you should optimize algorithms with two popular examples

Dhananjay Trivedi
The Startup

--

Algorithms are Everywhere

Whether it be scrapping the web to index pages, get your right Facebook posts, Netflix recommendation systems or be your Machine Learning algorithms that use to train your model, only with the right knowledge you would be able to train your model in hours and not in years.

How we optimize the Algorithms?

If you have to write an algorithm for Maximum PairWise Product in which you have to find out the maximum product of two numbers from the array.

A simple algorithm would be:

fun getMaxPairwiseProduct(listOfNumbers: IntArray): Int {
var result = 0
val n = listOfNumbers.size
for (i in 0 until n) {
for (j in i + 1 until n) {
if (listOfNumbers[i] * listOfNumbers[j] > result) {
result = listOfNumbers[i] * listOfNumbers[j]
}
}
}…

--

--