November 28, 2022

# Big O Notation

Sharing is caring!

The software engineering programming work field is really interesting, a software engineer though must be prepared to answer any kind of programming questions, using their programming language of choice, if he/she expect to be hired by a top programming company.

In today’s article we are going to be talking about the Big O Notation time and space in computer science.

The techniques and resources available to software engineers, can help them find solutions, for any kind of complex problems. Landau’s symbol or Big O notation is used to tell how fast a function grows or decline, in complex theory, computer science and mathematics.

The rate of growth of a function, is also known as its order, therefore the letter O is used, as the symbol for Big O time and space. The asymptotic behavior of functions, is described by the Big O time and space, which is also used in computer science particularly to describe the performance or complexity of an algorithm.

The Big O notation ranks an algorithms’ efficiency, by using O as the order of the function or its growth rate, and n as the the length of the array that is being sorted. Therefore we can use O(n) or O(n2) to express the run-time of an algorithms.

A function that runs or requires just one step, would be expressed as O(1), the input array could be 1 or 1000 items, one step would stile be the run time. The performance of an algorithm may grow linearly and in direct proportion to the size of the input data set, therefore, the O(n) would be used to describe the efficiency of such functions.

In Big O notation, there are three different types of time complexities known as: O(1) – constant time complexity, O(n) – linear time complexity, O(log n) – logarithmic time complexity and O(n2) – quadratic time complexity.

When an algorithms has nested iterations over a data set, then the O(n2) notation can be used, to describe its run-time.

Accessing a value with an array index in PHP is a good example of a O(1) run time.

For example

var arr = [ 1,2,3,4,5];

`arr[2]; // => 3`

Another type of time complexity in Big O notation is O(n!), which means that the execution time of the function, runs as the same rate as that of the factorial of the parameter n. Big O notation considers time, space and problems with data sizes.

Different types of performance analysis such as best case, average case, and worst-case analysis, are used to analyze the programming code performance. When the behavior of an algorithm is under optimal conditions, then it is said to be the best case analysis of the algorithm. When an algorithm performs worst for a given input and does not solve the problem, then it is said that the algorithm has a work-case performance.

When an average optimal algorithm is used to solve a problem, then it is said that the algorithm had an average performance, which was the performance analysis of that algorithm. One thing to note about Big O notation is that the input can be many things, such as an array, linked list, or nodes in a tree.