  C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD # I don't understand how the time complexity for this algorithm is calculated ## I don't understand how the time complexity for this algorithm is calculated Tag : c , By : Adam May Date : November 29 2020, 04:01 AM

I hope this helps . The reason why this is O(n) is because j is not set back to 0 in the body of the for loop.
Indeed if we take a look at the body of the for loop, we see:
``````while ( (j<N-1) && (A[i]-A[j] > D) )
j++;
``````
``````int j=0;
for (int i=0; i<N; i++) {
while ( (j<N-1) && (A[i]-A[j] > D) )
j++;
if (A[i]-A[j] == D)
return 1;
}
`````` Boards Message : You Must Login Or Sign Up to Add Your Comments .

## Banker's algorithm calculated time complexity

Tag : algorithm , By : user183275
Date : March 29 2020, 07:55 AM
Any of those help The Banker's algorithm is used to determine if all requests for resources can be satisfied without leading to a deadlock. , The below part introduces (n*m) time complexity
``````for I = 1 to N do // *n times
if ((not FINISH[i]) and
NEEDi <= WORK) then // *m times, if it's an array search
``````
``````WORK = WORK + ALLOCATION_i; // also O(m) operation, vectors addition
``````

## Time Complexity of an algorithm : How to decide which algorithm after calculated the time

Tag : java , By : pttr
Date : March 29 2020, 07:55 AM
will help you He said that because 10N + 8 is a linear equation. If you plot that equation you get a straight line. Try typing 10 * x + 8 on this website (function graphs) and see for yourself.

## Is time complexity of an algorithm calculated only based on number of times loop excecutes?

Tag : java , By : user183442
Date : March 29 2020, 07:55 AM
wish help you to fix your issue First note that in Big-O notation there is nothing such as O(n/2) as 1/2 is a constant factor which is ignored in this notation. The complexity would remain as O(n). So by modifying your code you haven't changed anything regarding complexity.
In general estimating the number of times a loop is executed with respect to input size and the operation that actually is associated with a cost in time is the way to get to the complexity class of the algorithm.

## Understand time complexity of algorithm to generate strings

Tag : c , By : user183442
Date : March 29 2020, 07:55 AM
hop of those help? I have an algorithm that takes as input 3 strings, with a strcat concat for each letter like this: , There are a couple of issues here.

## I don't understand this algorithm's Time Complexity

Tag : algorithm , By : arbeitandy
Date : March 29 2020, 07:55 AM
it should still fix some issue @blazs's answer seems correct. If that helps you understand, that's great. Here is an answer for visual learners like myself... 