Questions tagged [computational-complexity]

Use for questions about the efficiency of a specific algorithm (the amount of resources, such as running time or memory, that it requires) or for questions about the efficiency of any algorithm solving a given problem.

Computational complexity is a part of theoretical computer science that answers questions about how efficient an algorithm is:

  • How much time (as a function of the size of the input) does the algorithm take to produce its output?
  • How much space (such as computer memory) does it require?
  • How much of some other resource does it consume? (For example, this can be the size of a logic circuit solving the problem, or the number of bits of randomness used by a probabilistic algorithm.)

We can similarly ask about the computational complexity of any algorithm that solves a given problem.

Often, very specific details of these answers (such as constant factors or additive terms) depend on specific details such as the computer you're using. To help deal with this, we often stick to determining the asymptotic complexity of an algorithm: see for more details.

A major problem in computational complexity is the P versus NP problem, which asks if a certain class of problems can be solved by an algorithm that runs in a number of steps that's a polynomial function of the input size.

3433 questions
0
votes
1 answer

Polynomial time vs. polynomial space

In my opinion it is trivial that if an algorithm is polynomial time in its input length then it is also polynomial space. Is this true and really trivial or do I overlook something? If it is wrong, what counterexamples do we have? (I know that for…
0
votes
1 answer

How to manually calculate the max $n$ s.t. $n!<100^{n-1}$?

Is it possible to calculate the maximum interface value for $n$ so that $n!<100^{n-1}$, without using computer or calculator? I thought of using Sterling but $$\ln n! = n \ln n - n + 1/2 \ln (2 \pi n) + 1/(12n) - ... $$ Needs calculating $\ln n$,…
athos
  • 5,177
0
votes
0 answers

About complexity theory

In complexity theory, The size of a linear circuit is given by the number of its nodes. What do we mean when we say superlinear size? and What do we mean when we say Nonlinear lower bounds?
Mehrema
  • 121
0
votes
0 answers

If $~f, g \in FP$. What can we say about function $h : x \to f(x)^{g(x)}$?

Let function $~f, g \in FP$. What can we say about function $h : x \to f(x)^{g(x)}$? I suggest that $h \in FP$, but I do not know how to formally prove this.
markovian
  • 451
0
votes
0 answers

What is the time complexity(in big O notation) given the following code and why?

The code provide below is number of divisors using prime factorization. #include using namespace std; vector primes; // we'll preload primes once at the beginning int countDivisor(int n) { int divisor = 1; for (int…
0
votes
1 answer

Multiplication algorithm

My approach: I counted the number of operations performed (with some effort), and the result was $\log(e)$. But, How can determine this with Master Theorem?, any hints, Thanks! : I counted the number of operations performed (with some effort), and…
MathUser
  • 335
0
votes
1 answer

Show that $6n^2+20n$ is not $\Omega ( n^3)$

I am trying to show that $6n^2+20n$ is not $\Omega( n^3)$ Thoughts: By definition there must exist a $c \in \Bbb R$ such that $6n^2+20n > cn^3$ for all $n \in N$. Any hints on how I can show this to be a contradiction algebraically would be…
0
votes
1 answer

How complexity of algorithms are compared

I have two algorithms one with complexity $O(100)$ and the other with complexity $O(270)$. Can anyone give me a clear explanation of what exactly this means and how they are compared?
tom
  • 3
0
votes
1 answer

complexity of $\ {n \choose n/3}$

I know that the complexity of this combination $\ {n \choose n/3}$ is of $\theta(n^{n/3})$ , but I'm in need of help proving it.
Ehsan
  • 25
  • 5
0
votes
0 answers

How can I solve this Big $O$ exercise?

How can I prove that $n \log_2(n) ∈ O(log(n!))$ is true? We start by supposing that $f(n)< c g(n)$ is true, which means that $n \log_2(n) > c \log(n!)$ for all $n>n_0$ and $c>0$.
Natalie
  • 39
0
votes
0 answers

Graham's Scan Polar coordinates

I have this set of six cartesian coordinates and i need to sort them in order to apply Graham's. But i can't figure out how to do that. P[0] = (1,1) , P[1] = (2,6), P[2] = (3,3), P[3] = (4, 2), P[4] = (5,4), P[5] = (6,5). The point with the lowest…
0
votes
2 answers

Why these algorithms have a linear complexity function?

Considering the following algorithms: int F (int N) { int n, i, sum=0; for (n=N; n>0; n=n/2) for (i=0; i
Bruno A
  • 81
0
votes
1 answer

complexity for $f(x)=n!$ and O($2^n$)

Suppose that algorithm has O($n!$). We all know that $n!$ should be smaller than $2^{2^n}$, but bigger than $2^n$. So, will O($n!$) be in EXPTIME (EXP)? Will we able to write O($n!$) as O($2^n$)?
Zat Mack
  • 575
0
votes
1 answer

How do you express "additional complexity"?

Let's say I have two algorithms, one of which is less efficient in the sense that the complexity in the $\mathcal{O}$ notation has an additional factor $n$ (so for example, one is $\mathcal{O}(n^2)$ while the other is only $\mathcal{O}(n)$. So how…
bers
  • 552
  • 1
  • 4
  • 17
0
votes
1 answer

How to find the Big-O of the difference/quotient of two funtions

I'm not sure if what I'm asking even makes sense but it's a property of big-O that if $T_1(n) = O(f(n))$ and $T_2(n) = O(g(n))$, then $T_1(n) + T_2(n) = O(f(n) + g(n))$, or less formally its $O(max(f(n), g(n)))$. And also $T_1(N) * T_2(n) = O(f(n) *…