Analyze the time complexity of the following for loop [closed] - performance

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need help with the following problem:
for i <- 5 to m do P(i)
where P(i) is executed (m-i) times provided m >= 3
I realize that this is the summation
But I'm not sure exactly how to calculate the run time from this. Any suggestions?

If you count complexity of P(i) as constant, then you have just loop m - 5 times - it will give you complexity O(m)

Related

Value of f in A* algorithm [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
In A* algorithm, if g=0 and h=0 then what will be the result of f?
I know f(x)=g(x)+h(x). So it is true that f(x) will be zero?
f(x) would be 0.
But this should hardly ever occur.
g(x)=0 means you had no costs to reach x (should only be the case for the starting point)
h(x)=0 means the heuristics says that the costs to reach the goal from x costs not more than 0 (means that you are at the goal)
so f(x)=0 should only be possible if you start at the goal.

Find a subset of intervals with minimum total cost which together still cover the initial interval [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Suppose we are given n intervals [xi;yi] for 1 <= i <= n, which together cover an interval [x0;y0]. Each interval [xi;yi] has a positive cost ci. Give an efficient algorithm to find a subset of intervals with minimum total cost which together still cover the interval [x0;y0].

Time Complexities of an Algorithm [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
What could be the best or easiest way for analyzing/solving time complexity of a program? Both for iterative and recursive methods. Thanks for your help
Count how many times your basic operation will be executed.
For example:
int a = 0;
for (int i = 0; i < 5; i++){
a += 1;
}
your basic operation is a+=1. so how many times will it be executed? for the example, 5. Now instead of 5, we use n. so how many times will your basic operation execute? n times. then you can say the time complexity is O(n). This also goes for the recursive methods.

Calculating Probability of (m or more) consecutive successes [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Number of independent trials is N, probability of success is p. I want to calculate
Probability of m consecutive successes.
Probability of m or more consecutive successes.
The numbers are very large, so the algorithm should be highly optimized.
N = 877646440
m = 79279,
p = 6204/6205 (or 0.999838839645447....)
I seem to have the answer on mathematical SE where I originally started this question. https://math.stackexchange.com/questions/1888887/easily-calculable-minimum-probability-for-m-or-more-consecutive-outcomes/1889372#1889372
I will implement that solution and update the questions.
Edit: I have gotten the answer on the mathematical SE question and implemented the solution.
Thanks

Design a Greedy algorithm for this preblem [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
In the interval covering problem, we are given n intervals
[s1,t1), [s2,t2), ···, [sn,tn)
such that
S i∈[n][si,ti) = [0,T).
The goal of the problem is to return a smallest-size set
S ⊆ [n]
such that
S i∈S[si,ti) = [0,T).
Design a greedy algorithm for this problem.
A greedy algorithm could be devised as follows. As long as there is a point p in [0,T) which is not contained in one of the already selected intervals, select an interval [s_i,t_i) , which must exist, since the union of all [s_i,t_i) is [0,T) as stated in the requirements. As the set of intervals [s_i,t_i) is finite, this procedure must terminate.

Resources