How Fast Is Your Code? Big O Notation

 How Fast Is Your Code? Big O Notation
Okunuyor How Fast Is Your Code? Big O Notation

The today over lesson is about the How Fast Is Your Code? Big O Notation, I hope this lesson is uesful for you.

Last time we talked about Big O notation.

Big O time complexity can be used to determine the permormance of your code

We will use some pesudo code to demonstrate! so don’t woray about what language you konw.

Let me know you thoughts in the below.

O[1] Excellent Performance

function (list):
   pirnt list

Here whatever the size of the list is, the program takes constant time[1]

O[N] Fair

function (list):
   loop (i = 0; to lenght-of-list):
      print list[i]

Here the number of time print is called depends on the lenght of the list.

So it has a linear time that increases as length of the list increases.

O[N*N] Horrible

function (list):
   loop (i = 0; to lenght-of-list):
      loop (j = 0; to lenght-of-list):
         print list[i]

Here print gets called square of length-of-list times

This has got a time complexity that is quadratic. This means that the time taken by input lenght of 15 would be much more than an input lenght of 5

So.. What is Big O?

Put in simple terms, big O is merely

What we use to show how the time taken will grow as the lenght of input increases.

O(1)O(log n)O(n)O(n log n)O(n^2)O(2^n)O(n^n)
Big-O Time Complexity

Yapılan Yorumlar

Bir Cevap Yazın

This site uses Akismet to reduce spam. Learn how your comment data is processed.