For instance if i have an algorithm that is O(N^2) and it will run for 10 seconds for a problem size of 1000. Now if i were to double the problem size to 2000 i want to know the approximate run time in seconds. I know the answer for it but i want to understand the logic on how to get to the answer. So here is what i am thinking.
N = 1000 , Therefore 1000^2 = 10 seconds
N = 2000, Therefore (2*1000)^2, // stuck here
Now i am not sure i mean i know it will be 40 seconds because 2 to the power of 2 is 4 and then you multiply the 10 seconds by 4 and get 40 seconds but not entirely sure if this is right thinking. Was wondering if someone can break it down in simple terms?
Aucun commentaire:
Enregistrer un commentaire