🖥️
Sunil Notebook
Interview Preparation
  • 📒Notebook
    • What is this about ?
  • System Design
    • 💡Key Concepts
      • 🌐Scalability
      • 🌐Latency Vs Throughput
      • 🌐Databases
      • 🌐CAP Theorem
      • 🌐ACID Transactions
      • 🌐Rate limiting
      • 🌐API Design
      • 🌐Strong Vs eventual consistency
      • 🌐Distributed tracing
      • 🌐Synchronous Vs asynchronous Communication
      • 🌐Batch Processing Vs Stream Processing
      • 🌐Fault Tolerance
    • 💎Building Blocks
      • 🔹Message
      • 🔹Cache
      • 🔹Load Balancer Vs API Gateway
    • 🖥️Introduction to system design
    • ⏱️Step By Step Guide
    • ♨️Emerging Technologies in System Design
    • ☑️System design component checklist
      • 🔷Azure
      • 🔶AWS
      • ♦️Google Cloud
    • 🧊LinkedIn feed Design
    • 🏏Scalable Emoji Broadcasting System - Hotstar
    • 💲UPI Payment System Design
    • 📈Stock Broker System Design - Groww
    • 🧑‍🤝‍🧑Designing Instagram's Collaborative Content Creation - Close Friends Only
    • 🌳Vending Machines - Over the air Systems
    • Reference Links
  • DSA
    • Topics
      • Introduction
      • Algorithm analysis
        • Asymptotic Notation
        • Memory
      • Sorting
        • Selection Sort
        • Insertion Sort
        • Merge Sort
        • Quick Sort
        • Quick'3 Sort
        • Shell Sort
        • Shuffle sort
        • Heap Sort
        • Arrays.sort()
        • Key Points
        • Problems
          • Reorder Log files
      • Stacks and Queues
        • Stack Implementations
        • Queue Implementations
        • Priority Queues
        • Problems
          • Dijkstra's two-stack algorithm
      • Binary Search Tree
        • Left Leaning Red Black Tree
          • Java Implementations
        • 2-3 Tree
          • Search Operation - 2-3 Tree
          • Insert Operation - 2-3 Tree
        • Geometric Applications of BST
      • B-Tree
      • Graphs
        • Undirected Graphs
        • Directed Graphs
        • Topological Sort
      • Union Find
        • Dynamic Connectivity
        • Quick Find - Eager Approach
        • Quick Find - Lazy Approach
        • Defects
        • Weighted Quick Union
        • Quick Union + path comparison
        • Amortized Analysis
      • Convex Hull
      • Binary Heaps and Priority Queue
      • Hash Table vs Binary Search Trees
  • Concurrency and Multithreading
    • Introduction
    • Visibility Problem
    • Interview Questions
    • References
      • System design
  • Design Patterns
    • ℹ️Introduction
    • 💠Classification of patterns
    • 1️⃣Structural Design Patterns
      • Adapter Design Pattern
      • Bridge Design Pattern
      • Composite Design Pattern
      • Decorator Design Pattern
      • Facade Design Pattern
      • Flyweight Design Pattern
      • Private Class Data Design Pattern
      • Proxy Design Pattern
    • 2️⃣Behavioral Design Patterns
      • Chain Of Responsibility
      • Command Design Pattern
      • Interpreter Design Pattern
      • Iterator Design Pattern
      • Mediator Design Pattern
      • Memento Design Pattern
      • Null Object Design Pattern
      • Observer Design Pattern
      • State Design Pattern
      • Strategy Design Pattern
      • Template Design Pattern
    • 3️⃣Creational Design Patterns
      • Abstract Factory Design Pattern
      • Builder Design Pattern
      • Factory Method Design Pattern
      • Object Pool Design Pattern
      • Prototype Design Pattern
      • Singleton Design Pattern
    • Java Pass by Value or Pass by Reference
  • Designing Data-Intensive Applications - O'Reilly
    • Read Me
    • 1️⃣Reliable, Scalable, and Maintainable Applications
      • Reliability
      • Scalability
      • Maintainability
      • References
    • 2️⃣Data Models and Query Languages
      • Read me
      • References
    • Miscellaneous
  • Preparation Manual
    • Disclaimer
    • What is it all about?
    • About a bunch of links
    • Before you start preparing
    • Algorithms and Coding
    • Concurrency and Multithreading
    • Programming Language and Fundementals
    • Best Practices and Experience
  • Web Applications
    • Typescript Guidelines
  • Research Papers
    • Research Papers
      • Real-Time Data Infrastructure at Uber
      • Scaling Memcache at Facebook
  • Interview Questions
    • Important links for preparation
    • Google Interview Questions
      • L4
        • Phone Interview Questions
      • L3
        • Interview Questions
      • Phone Screen Questions
  • Miscellaneous
    • 90 Days Preparation Schedule
    • My Preparation for Tech Giants
    • Top Product Based Companies
  • Links
    • Github
    • LinkedIn
Powered by GitBook
On this page
  • Worst Case Running Time
  • Lower Bound and Upper Bound
  • Upper bound
  • Lower bound
  • Reference

Was this helpful?

Edit on GitHub
  1. DSA
  2. Topics
  3. Algorithm analysis

Asymptotic Notation

Worst Case Running Time

For an algorithm AAA, t(x) represents the number it of steps it takes to process input x using algorithm A.

The worst case run time for processing data set TA(n)T_A(n)TA​(n)

Worst case running time looks at the number of steps it takes at most to go through an algorithm for input of size n

T(n)={max t(x), where x is input of size n}T(n) = \{ max \ { t(x), \ where \ x \ is \ input \ of\ size \ n } \}T(n)={max t(x), where x is input of size n}

Thus, what it means is that if we looked at all possible inputs of size n the set of inputs that lead to the most steps is the expression we use for T(n). In practice it isn't really practical to look at every possible set of input of size n, and thus, we typically argue for a set of input that will lead to doing the most operations possibles.

Lower Bound and Upper Bound

Upper bound

The upper bound is typically expressed with big-O notation. Note that upper bound is not just applicable to worst case. Upper bound can be applied to worst case, average even best case.

" T(n)T(n)T(n) is in O(f(n))O(f(n))O(f(n))" iff for some constants ccc and n0n_0n0​, T(n)≤cf(n)T(n) \leq c f(n)T(n)≤cf(n) for all n≥n0​​n \geq n_0​​n≥n0​​​

Lower bound

Similar to upper bound, a lower bound is not something that only applies to best case run time. The lower bound of a function is described by big - Ω\OmegaΩnotation. Formally:

" T(n)T(n)T(n) is in Ω(f(n))\Omega(f(n))Ω(f(n))" iff for some constants ccc and n0n_0n0​, T(n)≥cf(n)T(n) \geq c f(n)T(n)≥cf(n) for all n≥n0​​n \geq n_0​​n≥n0​​​

To prove this, what we need to argue is simply that there is at least one set of input of size n for which f(n) is the lower bound (at least c*f(n) steps must be taken to handle that particular input).

Reference

PreviousAlgorithm analysisNextMemory

Last updated 3 years ago

Was this helpful?

https://www.bigocheatsheet.com/
Common Data Structure Operations
Array Sorting algorithms
BIG-0 Cheat sheet