Coder Social home page Coder Social logo

big-o-notation's Introduction

big-o-notation

Analysis of algorithms is the most important step for software development. A well-written algorithm is not only time-efficient but also space-efficient. The complexity of algorithms is measured using asymptotic notations. Using these notations, we can determine if an algorithm performs better than the other one. Coding interviews often include questions regarding complexity analysis of algorithms, or they might ask you to implement the most efficient algorithms. To answer such questions you should be able to calculate the complexity of any algorithm.

General Tips#

  • Every time a list or array gets iterated over c×length times, it is most likely in O(n) time.
  • When you see a problem where the number of elements in the problem space gets halved each time, it will most probably be in O(log n) runtime.
  • Whenever you have a single nested loop, the problem is most likely in quadratic time.

Big-O Notation analyzes the efficiency of an algorithm as its input approaches infinity.

The following table lists some commonly encountered functions in ascending order of rate of growth (Best to Worst)

  1. Any constant Constant
  2. log n - Logarithmic
  3. log^2 n - Log-square
  4. sqrt n - Root-n
  5. n - Linear
  6. nlogn - Linearithmic
  7. n^2 - Quadratic
  8. n^3 - Cubic
  9. n^4 - Quartic
  10. 2^n - Exponential
  11. e^n - Exponential
  12. n! - n-Factorial

big-o-notation's People

Contributors

kartheekmusalimadugu27 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.