Top "Complexity-theory" questions

Computational complexity theory is a branch of the theory of computation in theoretical computer science and mathematics that focuses on classifying computational problems according to their inherent difficulty.

Can an O(n) algorithm ever exceed O(n^2) in terms of computation time?

Assume I have two algorithms: for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { //do …

big-o complexity-theory time-complexity
Why does decreasing K in K-nearest-neighbours increase complexity?

In an extract from my textbook it says that reducing the value of K when running this algorithm actually increases …

algorithm artificial-intelligence complexity-theory nearest-neighbor
How to count distinct values in a list in linear time?

I can think of sorting them and then going over each element one by one but this is nlogn. Is …

algorithm list count complexity-theory distinct-values
Finding the closest fibonacci numbers

I am trying to solve a bigger problem, and I think that an important part of the program is spent …

c++ algorithm math complexity-theory discrete-mathematics
c++ practical computational complexity of <cmath> SQRT()

What is the difference in CPU cycles (or, in essence, in 'speed') between x /= y; and #include <cmath> …

c++ complexity-theory sqrt cpu-cycles cpu-time
Why is P ⊆ co-NP?

I've seen several places that have simply stated that it's known that P is a subset of the intersection of …

algorithm complexity-theory theory np
What is the A* time complexity and how is it derived?

I was wondering if anyone could explain the A* time complexity. I am using a heuristic that uses euclidean distance …

time complexity-theory a-star
How do I explain what a "naive implementation" is?

What is the clearest explanation of what computer scientists mean by "the naive implementation"? I need a good clear example …

language-agnostic complexity-theory
Why is the complexity of BFS O(V+E) instead of O(V*E)?

Some pseudocode here (disregard my style) Starting from v1(enqueued): function BFS(queue Q) v2 = dequeue Q enqueue all unvisited …

algorithm complexity-theory breadth-first-search
Example problems not in P nor in NP-complete but in NP

I have a course called Algorithm Analysis at college, where we're currently studying the different complexity classes -- P, NP, …

computer-science theory complexity-theory computation-theory