w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
what to take as n in complexity of algorithms

I think there is no disagreement.

The algorithm has linear runtime complexity. It takes twice as long for a range double the size.

You both agree that complexity is O(n). Both in terms of number of iterations (the book) and in terms of number of machine instructions (you). Your two ways of counting should be roughly equivalent in gauging the time it takes to run (which is what runtime complexity is about).

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.