Algorithms and Big O

William Lin
3 min readJun 18, 2020

--

What I understand so far.

According to Dictionary.com, the definition of an algorithm is a set of rules for solving a problem in a finite number of steps, as for finding the greatest common divisor.

Honestly, who can understand that gibberish? Algorithms are just the steps to take to complete a task. When you make a sandwich, you have to go through a certain number of steps to complete making a sandwich. We can say that making a sandwich requires an algorithm.

When you go shopping, you might like to linger in the dairy aisle or the snack aisle to pick out your products. That’s how you shop and it’s an algorithm. Whenever anyone programs, they are essentially passing steps that the computer understands to take to complete something.

Why are algorithms important?

Algorithms are important because they are passed down to replicate certain tasks. If you don’t know the steps to do something, you can watch a youtube tutorial which gives you the steps on how to do something.

Algorithms are especially important because you can teach a computer the steps to automate tasks. These tasks can take computers less time to complete than a human would. For example, a computer can calculate the 6781/673123.5 faster than a human can usually. Algorithms are used everywhere in our daily lives from comparing numbers, solving math problems, to even guessing routes to take and mimicking decisions from humans.

Algorithms are documented so that when another problem with similar roadblocks occur, the programmer can choose to reference a previous algorithm when creating one for the computer for this specific task.

What is Big O Notation?

According to MIT: Big O notation (with a capital letter O, not a zero), also called Landau’s symbol, is a symbolism used in complexity theory, computer science, and mathematics to describe the asymptotic behavior of functions. Basically, it tells you how fast a function grows or declines.

Keep in mind that an asymptote is something a line that curves towards something as it reaches infinity.

O(f(n))

An asymptote is important when used to describe the Big O notation because it’s dealing with values that humans can't comprehend in the array inputs.

Big O notation is a mathematical calculation of how efficient an algorithm is. This is efficiency is represented by how much time it takes for an algorithm to complete a task as the task’s set approaches infinity. For a given algorithm, there is an input, an output, and the time it takes to complete the algorithm. There can be many different algorithms to solve a specific task with the same outcome from the same exact input set N. N represents the number of elements in the array that the function is being acted upon. While these solutions are valid, some are more valid than others because they accomplish the task faster. Honestly, I don’t know how to calculate Big O but it basically is the number of steps it takes to get the answer. Keep in mind, certain functions do not change the time it takes to complete a task and those functions will have a constant time because the amount of operations the function runs is limited.

Visualizations of commonly found O’s of functions.

source: https://www.bigocheatsheet.com/
source: MIT Big O lecture

Here are some helpful links

--

--

No responses yet