Questions tagged [runtime-analysis]

Questions about methods for estimating the increase in runtime of an algorithm as the input size increases.

This question is for analysis of the running time of an algorithm, especially asymptotic running time analysis.

Make sure to refer to our reference questions before asking about the running time of an algorithm:

Many elementary questions about running time can be solved using the techniques in those reference questions, so make sure to check whether your problem can be solved using those standard techniques before asking. Questions asking about elementary aspects of runtime analysis (e.g., undergraduate-level exercises) that don't demonstrate knowledge of these techniques might be closed as a duplicate of the reference question.

1036 questions
10
votes
2 answers

Multiplication in $O(n\cdot \log n)$

I was looking in here, and I noticed the best runtime for multiplication of two $n$-bits numbers is $O(n\cdot \log n \cdot 2^{O(\log^* n)}$, but I can easily notice an algorithm that runs in $O(n\cdot \log n)$. After all, we know how to multiply…
TheEmeritus
  • 523
  • 2
  • 8
2
votes
1 answer

Average Case Analysis for finding max in array with duplicated element

I've read some posts about counting the number of assignment inside code of finding the maximum value in array like this: FindMax(L): n = len(L) max = L[1] for i = 2..n: if (max < L[i]) max = L[i] (**) return…
2
votes
1 answer

Finding running time

Apologies for this simple question. I found it in the book Algorithms by Sedgewick and Wayne. Give a formula to predict the running time of a program for a problem of size N when doubling experiments have shown that the doubling factor is $2^b$ and…
johnson
  • 123
  • 2
2
votes
0 answers

One algorithm for turnpike reconstruction problem?

In << Data Structure and Algorithm Analysis >>, turnpike reconstruction problem is given for demo of backtracking. Suppose we are given n points, p1 , p2 , . . . , pn , located on the X -axis. Xi is the x coordinate of pi . Let us further assume…
2
votes
1 answer

Does this program have a runtime of O(N) or O(n*m)

This question is similar to, but distinct from this one, in that I am considering a specific case that demonstrates an apparent inconsistency in how I see Big-O notation used. I would like to be sure I am properly evaluating the run time of this…
Brian C
  • 121
  • 3
2
votes
2 answers

Runtime complexity of algorithm that subtracts progressively larger amounts

How would you describe the runtime complexity if I have an algorithm that at each step, the size of the array reduced by an exponentially-increasing amount? For example, for each step in the algorithm, it is actually processing n - 2^k items, where…
tau
  • 135
  • 3
2
votes
1 answer

Can one find an algorithm whose running time is larger than Ackermann's function?

Is there an example of an algorithm whose time complexity is strictly larger than Ackermann's function?
user2219896
  • 123
  • 4
1
vote
1 answer

Understanding the closed form derivation on the function f(n/3) + n^2 +3

I have the function: $$ f(n) = \begin {cases} 4 & , n = 1 \\ f(\frac{n}{3}) + n^2 -3 & , n \ge2 \end {cases} $$ The given solutions shows the unwinding of the function as follows: Assuming $ n \ge 2$ $$f(n) = f\bigg(\frac{n}{3}\bigg) + n^2 -…
R83nLK82
  • 41
  • 4
1
vote
0 answers

k-Circle Cover - How to show the faster algorithm isn't slower

I am having two algorithms, of which the second is a refinement of the first. However, I am having trouble to show that the seemingly better algorithm runs at least as fast as the first algorithm. The algorithms aim to be FPT with respect to the…
Sudix
  • 709
  • 3
  • 12
1
vote
1 answer

Can you substitute functions in Big-$\Theta$ notation?

Say we have some function $f(n)=\Theta(\log n)$ and another function $g(n)=\Theta(n+\log n)$. Is it valid to substitute $f(n)$ for $\log n$, giving us $g(n) = \Theta(n + f(n))$? This seems obvious to me but I'm not sure if there is a weird edge case…
Henry
  • 13
  • 2
1
vote
2 answers

Running time question

If I have two kinds of LinkedList $A$ and $B$. $A$ is a move to front one which means: >>> lst1 = 1, 2, 3, 4, 5, 6, 7, 8, 9 >>> lst1.contain(7) True >>> lst1.to_list 7, 1, 2, 3, 4, 5, 6, 8, 9 $B$ is a swap list, which means: >>> lst2 = 1, 2, 3, 4,…
Joe1002
  • 11
  • 2
1
vote
1 answer

Can a more powerful encoding of an input make an algorithm that is polynomial in the number of inputs become exponential?

This is probably a very basic question but one that I am having trouble finding a definitive answer for since this kind of thing is skimmed over in most introductory algorithms courses. Take an algorithm like DFS that runs in time polynomial in the…
kanso37
  • 435
  • 2
  • 13
1
vote
1 answer

Given a set of sets, find the magnitude (number of elements) of the smallest set containing at least one element from each set

I know that the hitting problem is NP hard, but is it possible to find the magnitude of the smallest set? Also, provide the runtime.
0
votes
1 answer

Time Complexity of Basic Primality Test Algorithm

The algorithm I'm referring to is one of the most fundamental primality checks: For a number, $n$, check if it is divisible by some odd number, $k$, less than or equal to $\sqrt{n}$. Assume $n$ is a fixed size and that all basic arithmetic…
Badr B
  • 207
  • 2
  • 10
0
votes
2 answers

Runtime analysis of bit operations

In class we have learned that division takes O($k^2$) where k is the bitlength of the numbers used in the operation. What would be the runtime of a function that looks like this? while a % 2 == 0: a = a / 2 I am guessing the worst case is…
eatorres
  • 3
  • 2
1
2