it is actually just O(n).. (not O(n+n), not O(2n), not O(n^n), just O(n) )
because since you increment j
up to n
in the inner loop
as soon as you finish the inner loop of n
elements, the outer condition will be false.. so it will exit, after n
iterations
More Related Contents:
- Calculate the sum with minimum usage of numbers
- Complexity of absolute difference and sum
- What is a plain English explanation of “Big O” notation?
- Understanding recursion [closed]
- Why do we check up to the square root of a number to determine if the number is prime?
- How to create the most compact mapping n → isprime(n) up to a limit N?
- Mapping two integers to one, in a unique and deterministic way
- Algorithm for N-way merge
- John Carmack’s Unusual Fast Inverse Square Root (Quake III)
- Leap year calculation
- Backtracking in A star
- What algorithms compute directions from point A to point B on a map?
- Count number of 1’s in binary representation
- What is dynamic programming? [closed]
- Puzzle: Find largest rectangle (maximal rectangle problem)
- How can I calculate the age of a person in year, month, days?
- Performing Breadth First Search recursively
- Find the index of a given permutation in the sorted list of the permutations of a given string
- What is the most efficient algorithm to find a straight line that goes through most points?
- Closest point to a given point
- What is amortized analysis of algorithms? [closed]
- How modern X86 processors actually compute multiplications?
- how do I create a line of arbitrary thickness using Bresenham?
- need an algorithm for collapsing netblock ranges into lists of superset ranges
- Unbiased random number generator using a biased one
- Why is vector array doubled?
- maximum subarray of an array with integers [duplicate]
- CUDA stream compaction algorithm
- Can brute force algorithms scale?
- Best algorithm for matching colours.