algorithmtime-complexitybig-o

Examples of Algorithms which has O(1), O(n log n) and O(log n) complexities


What are some algorithms which we use daily that has O(1), O(n log n) and O(log n) complexities?


Solution

  • If you want examples of Algorithms/Group of Statements with Time complexity as given in the question, here is a small list -

    O(1) time

    O(n) time

    In a nutshell, all Brute Force Algorithms, or Noob ones which require linearity, are based on O(n) time complexity


    O(log n) time


    O(n log n) time

    The factor of 'log n' is introduced by bringing into consideration Divide and Conquer. Some of these algorithms are the best optimized ones and used frequently.


    O(n^2) time

    These ones are supposed to be the less efficient algorithms if their O(nlogn) counterparts are present. The general application may be Brute Force here.


    O(n!) time