algorithm to display squares and cubes of first 10 number
Answers
Answer:
Different processors work with disparate speeds. For any given processor, elementary operations differ in terms of their speeds and computational complexities. The paper presents an algorithm to compute cubes of 1st “N” Natural Numbers using one multiplication by constant, two additions on variables and one addition by constant, per iteration. Theoretically, computational complexity of multiplication is O(n2) while that of addition is Θ(n), where n is the number of bits used to represent that number. So, keeping the number of iterations same in both, in the traditional approach, the overall computational complexity per iteration is expressed in the order of O(n2) while in the current approach the overall computational complexity per iteration is of the order of O(n). For small values of “N”, the difference in complexities may not be huge. But, given any large value of “N”, difference will be noticeable.
Computational complexities of linear (n) and quadratic/square (n 2 ) functions
Computational complexities of linear (n) and quadratic/square (n 2 ) functions
…
Elementary operations with their time complexities
Elementary operations with their time complexities
…
Values for N=10
Values for N=10