Wednesday, 13 January 2021

BIG O Notation


It is very important to analyze the algorithm, but before that we must know what is algorithm.

Algorithm is nothing but the procedure of solving problem.(Ex for algorithm)

If you are making a Cup of Tea what is the procedure?  Adding tea powder is imp without this how can you say the end product is Tea, sugar quantity varies person to person and you need to heat till the Tea ready the way you want. olla!!!!! Tea is ready. 

Similarly you need to use the functions, variables and conditionals statement to achieve your end desire.

There are some best procedures (Algorithms)to solve problems and they have names as well. Ex (Euclid algorithm to get HCF of a number)


How to compare algorithm:

To compare algorithm we use Big -O notation

Big - O notation represents the complexity of an algorithm. Here I mean Time complexity and space Complexity.

We can compare algorithm over time and memory allocation, but the speed is also depend on the hardware we used to run it.

 In simple words if the user input increases how much  time it took to run the code and how much space it require. If input increases linearly and time increases linearly as well it comes under worst case.



Runtimes of Big-O Functions

Here is a table of common Big-O functions:


Big-OName
1Constant
log(n)Logarithmic
nLinear
nlog(n)Log Linear
n^2Quadratic
n^3Cubic
2^nExponential


Sources:

No comments:

Post a Comment

Author Details

Hi, I'm Prashant — a full-time software engineer with a passion for automation, DevOps, and sharing what I learn. I started Py-Bucket to document my journey through tools like Docker, Kubernetes, Azure DevOps, and PowerShell scripting — and to help others navigate the same path. When I’m not coding or writing, I’m experimenting with side projects, exploring productivity hacks, or learning how to build passive income streams online. This blog is my sandbox — and you're welcome to explore it with me. Get in touch or follow me for future updates!

About Me

About the Author

Author

Hi, I'm Prashant — a full-time software engineer with a passion for automation, DevOps, and sharing what I learn. I started Py-Bucket to document my journey through tools like Docker, Kubernetes, Azure DevOps, and PowerShell scripting — and to help others navigate the same path.

When I’m not coding or writing, I’m experimenting with side projects, exploring productivity hacks, or learning how to build passive income streams online. This blog is my sandbox — and you're welcome to explore it with me.

Get in touch or follow me for future updates!