ITEMS | ALGORITHM1(ms) | ALGORITHM2(ms) |
---|---|---|
200 | 20 | 40 |
1000 | 100 | 1000 |
10000 | 1000 | 100000 |
items | algorithm1(ms) | algorithm2(ms) |
---|---|---|
200 | 20 | 40 |
1000 | 100 | 1000 |
10000 | 1000 | 100000 |
linear growth | quadratic growth |
Assumptions made are:
12 | 8 | 7 | 5 | 2 |
---|
8 | 7 | 5 | 2 | 12 |
---|
comparison | swap |
---|---|
1 | 3 |
1 | 3 |
1 | 3 |
1 | 3 |
total ops: 16
7 | 5 | 2 | 8 | 12 |
---|
comparison | swap |
---|---|
1 | 3 |
1 | 3 |
1 | 3 |
total ops: 12
5 | 2 | 7 | 8 | 12 |
---|
comparison | swap |
---|---|
1 | 3 |
1 | 3 |
total ops: 8
2 | 5 | 7 | 8 | 12 |
---|
comparison | swap |
---|---|
1 | 3 |
total ops: 4
16+12+8+4
= 4(4+3+2+1)
= 4 (n-1+ n-2 + ... 3 + 2 + 1)
= 2 * n * (n - 1)
= pn^2 + qn + r