|
-
December 18th, 2014, 03:37 AM
#6
Re: Specify how many times elements of array will be compared [Bubble sort]
 Originally Posted by Snape
So when the array length is 10 average=(near)length*2 but when array length is 100 average=(near)length*2,3
Should it help me or this information is worthless?
Your test shows that the algrithm has O(N^2) complexity indeed.
When you make the array 10 times bigger the test takes 10^2 = 100 times longer.
This trend should stick. For example if you make the array 25 times larger (array length = 250) the test will take 25^2 = 625 times longer.
Note that complexity measures are not exact, they show the overall trend. But it's a valuable hint in practice as to how your program will scale when the the input load is increased (like for example a much bigger array is used).
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|