Is O(Kn) Linear Complexity or Quadratic Complexity? or Does It Depend on the K?

If n is very big, and k is very small, can I say that O(kn) is linear complexity?

What if k is closed to n/2, but not more than n/2? Do I consider it still as linear complexity? Or quadratic complexity O(n^2)?

Is there a limit to how big k is, to consider O(kn) as quadratic complexity?

2 Answers

If k is a constant, then any O(kn) function is O(n), i.e. linear

If k is a function of n and is O(n), then any O(kn) function is O(n^2). n/2 is O(n). Furthermore, (n^2)/2 is not O(n), and so if k is close to n/2 then kn is not O(n).

If k is not O(n), then kn is not O(n^2).

2

Assuming that k and n are independent variables, saying O(kn) is linear is a proper statement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest