ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Design and Analysis of Algorithms
    COMP3138
    Progress0 / 53 topics
    Topics
    1. Introduction to Algorithm Design2. Data Structures3. Efficiency in Algorithms4. Analysis of Algorithms5. Mathematical Review6. Mathematical Analysis of Algorithms7. Types of Functions8. Order of Growth9. Asymptotic Notations10. Sorting Algorithms11. Selection Sort Algorithm12. Example and Analysis of Selection Sort13. Insertion Sort Algorithm14. Divide and Conquer Algorithms15. Merge Sort Algorithm16. Quick Sort Algorithm17. Bucket Sort Algorithm18. Radix Sort Algorithm19. Counting Sort Algorithm20. Heap Sort Basics21. Heap Algorithms22. Heap Properties and Examples23. Heap Operations24. Heap Sort Algorithm Analysis25. Heap Insertion and Deletion26. Tree Based Algorithms and Hashing27. Red Black Tree Basics28. Binary Search Tree Basics29. Tree Searching Algorithms30. Analysis of Tree Searching Algorithms31. Analysis of Insertion and Deletion in BST32. Hashing Basics33. Examples of Hash Functions34. Analysis of Collision Resolution Techniques35. Dynamic Programming36. 0-1 Knapsack Problem37. Fractional Knapsack Problem38. Longest Common Subsequence39. Shortest Path Finding40. Matrix Chain Multiplication41. Assembly Line Chain Problem42. Greedy Algorithms43. Prim's Algorithm44. Kruskal's Algorithm45. Dijkstra's Algorithm46. Huffman Coding47. NP-Completeness48. Polynomial Time Verification49. Reducibility50. NP-Completeness Proofs51. Randomized Algorithms52. Particle Swarm Optimization53. Genetic Algorithms
    COMP3138›Asymptotic Notations
    Design and Analysis of AlgorithmsTopic 9 of 53

    Asymptotic Notations

    8 minread
    1,339words
    Intermediatelevel

    Asymptotic Notations in Algorithm Analysis

    Asymptotic notation is a mathematical tool used to describe the behavior of an algorithm in terms of time or space complexity as the input size approaches infinity. These notations provide an abstract way to express the efficiency and growth rate of algorithms, allowing us to compare different algorithms and understand their scalability for large inputs.

    The three main asymptotic notations used in computer science are:

    1. Big-O (O) Notation
    2. Big-Ω (Ω) Notation
    3. Big-Θ (Θ) Notation

    Each notation describes the algorithm’s performance from a different perspective, such as the worst-case, best-case, or average-case behavior.


    1. Big-O Notation (O)

    Big-O notation describes the upper bound of an algorithm’s running time or space complexity. It represents the worst-case scenario, showing the maximum growth rate of the algorithm as the input size increases. Big-O notation is typically used to express an algorithm’s upper limit on performance.

    Definition:

    An algorithm is said to have a time or space complexity of O(f(n)) if, for sufficiently large n, the algorithm’s running time or space will not exceed a constant multiple of f(n). Formally, there exist constants c and n₀ such that for all n ≥ n₀, the running time T(n) satisfies:

    T(n)≤c⋅f(n)T(n) \leq c \cdot f(n)T(n)≤c⋅f(n)

    Key Points:

    • Describes the worst-case performance.
    • Provides an upper bound on the algorithm's growth rate.
    • Often used to describe the time complexity of an algorithm.

    Example:

    • O(n): An algorithm with O(n) time complexity grows linearly with the input size n. An example is linear search in an unsorted array, where each element is checked until the target is found.
    for (int i = 0; i < n; i++) {
        if (arr[i] == target) {
            return i;
        }
    }
    

    2. Big-Ω Notation (Ω)

    Big-Ω notation describes the lower bound of an algorithm’s running time or space complexity. It represents the best-case scenario, showing the minimum growth rate of the algorithm as the input size increases. It gives an idea of the minimum time or space an algorithm will need to solve a problem.

    Definition:

    An algorithm is said to have a time or space complexity of Ω(f(n)) if, for sufficiently large n, the algorithm's running time or space will be at least a constant multiple of f(n). Formally, there exist constants c and n₀ such that for all n ≥ n₀, the running time T(n) satisfies:

    T(n)≥c⋅f(n)T(n) \geq c \cdot f(n)T(n)≥c⋅f(n)

    Key Points:

    • Describes the best-case performance.
    • Provides a lower bound on the algorithm's growth rate.
    • Used to describe the minimum amount of work an algorithm must do, even in the best case.

    Example:

    • Ω(n): A linear search in an unsorted array will take at least O(n) comparisons in the worst case, but the best-case performance occurs when the target element is the first item in the array. Thus, the best-case time complexity is Ω(1), since the algorithm only requires one comparison in the best case.

    3. Big-Θ Notation (Θ)

    Big-Θ notation provides a tight bound on an algorithm’s running time or space complexity. It represents both the upper and lower bounds, giving an exact description of the algorithm’s growth rate. When an algorithm’s time complexity is described as Θ(f(n)), it means the algorithm’s growth rate is bounded both from above and below by f(n), within constant factors.

    Definition:

    An algorithm is said to have a time or space complexity of Θ(f(n)) if there exist constants c₁, c₂, and n₀ such that for all n ≥ n₀, the running time T(n) satisfies:

    c1⋅f(n)≤T(n)≤c2⋅f(n)c₁ \cdot f(n) \leq T(n) \leq c₂ \cdot f(n)c1​⋅f(n)≤T(n)≤c2​⋅f(n)

    Key Points:

    • Describes the exact growth rate of the algorithm.
    • Provides both upper and lower bounds.
    • Used when you want to describe an algorithm’s performance accurately in terms of growth.

    Example:

    • Θ(n): An algorithm with Θ(n) time complexity grows linearly with the input size n. For example, linear search on an unsorted array has a time complexity of Θ(n), because it will take at least n comparisons in the worst case and exactly n comparisons when it scans all elements.

    4. Little-O Notation (o)

    Little-o notation describes the strict upper bound of an algorithm's growth rate. It is similar to Big-O, but it implies that the algorithm’s running time or space complexity grows strictly slower than a function f(n) as n grows large.

    Definition:

    An algorithm is said to have a time or space complexity of o(f(n)) if, for any constant c > 0, there exists an n₀ such that for all n ≥ n₀, the running time T(n) satisfies:

    T(n)<c⋅f(n)T(n) < c \cdot f(n)T(n)<c⋅f(n)

    Key Points:

    • Describes an upper bound, but the growth rate is strictly slower than the given function.
    • Can be used to say that an algorithm grows slower than a certain complexity, but without ever matching it.

    Example:

    • o(n²): If an algorithm has o(n²) time complexity, it means that the time complexity grows slower than n² and is not equal to n² for large inputs.

    5. Little-Ω Notation (ω)

    Little-Ω notation describes the strict lower bound of an algorithm’s running time or space complexity. It means that the algorithm’s growth rate will eventually outpace a given function f(n).

    Definition:

    An algorithm is said to have a time or space complexity of ω(f(n)) if, for any constant c > 0, there exists an n₀ such that for all n ≥ n₀, the running time T(n) satisfies:

    T(n)>c⋅f(n)T(n) > c \cdot f(n)T(n)>c⋅f(n)

    Key Points:

    • Describes a lower bound, but the growth rate is strictly faster than the given function.
    • Used when an algorithm's complexity grows faster than a given function.

    6. Comparison of Asymptotic Notations

    Notation Description Bound Example
    Big-O Upper bound (worst-case) T(n) ≤ c * f(n) O(n²) for bubble sort
    Big-Ω Lower bound (best-case) T(n) ≥ c * f(n) Ω(n) for linear search
    Big-Θ Tight bound (exact growth rate) c₁ * f(n) ≤ T(n) ≤ c₂ * f(n) Θ(n) for linear search
    Little-o Strict upper bound (grows strictly slower) T(n) < c * f(n) o(n²) for an algorithm slower than quadratic growth
    Little-Ω Strict lower bound (grows strictly faster) T(n) > c * f(n) ω(n log n) for algorithms that grow faster than linearithmic

    Summary of Asymptotic Notations

    • Big-O (O): Provides the worst-case scenario and gives the upper bound on an algorithm's growth rate.
    • Big-Ω (Ω): Provides the best-case scenario and gives the lower bound on an algorithm's growth rate.
    • Big-Θ (Θ): Provides a tight bound and gives an exact growth rate, describing both upper and lower bounds.
    • Little-o (o): Describes a strict upper bound, meaning the algorithm grows strictly slower than the given function.
    • Little-Ω (ω): Describes a strict lower bound, meaning the algorithm grows strictly faster than the given function.

    Conclusion

    Asymptotic notations are essential tools in algorithm analysis, allowing us to express and compare the growth rates of different algorithms in a rigorous and abstract way. By using Big-O, Big-Ω, and Big-Θ, we can describe an algorithm's performance in terms of time and space complexity, and choose the most efficient one for a given problem.

    Previous topic 8
    Order of Growth
    Next topic 10
    Sorting Algorithms

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time8 min
      Word count1,339
      Code examples0
      DifficultyIntermediate