Added Big O Efficiency Table.
This commit is contained in:
parent
9c577f1330
commit
2f6b87d20d
@ -33,6 +33,26 @@ Algorithm Design Block
|
|||||||
return counter, comps
|
return counter, comps
|
||||||
|
|
||||||
Big-O Analysis: (Based on Implementation)
|
Big-O Analysis: (Based on Implementation)
|
||||||
|
| if(B) | incr substring |
|
||||||
|
init Comps | init values | i | if(a) | j | min max | min max |
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
1 | 1 | 1 | 1 | n-2 | 0 n-2 | 0 n-2 |
|
||||||
|
| | 2 | 1 | n-3 | 0 n-3 | 0 n-3 |
|
||||||
|
| | 3 | 1 | n-4 | 0 n-4 | 0 n-4 |
|
||||||
|
| | 4 | 1 | n-5 | 0 n-5 | 0 n-5 |
|
||||||
|
| | 5 | 1 | n-6 | 0 n-6 | 0 n-6 |
|
||||||
|
| | . | . | ... | . ... | . ... |
|
||||||
|
| | n | 1 | 0 | 0 0 | 0 0 |
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
1 | 1 | X | n | X | 0 n^(2)-n| 0 n^(2)-n|
|
||||||
|
------- -------
|
||||||
|
2 2
|
||||||
|
|
||||||
|
Best-Case Scenario: n + 0 + 0 = n
|
||||||
|
Worse-Case Scenario: n + (n^(2)-n)/2 + (n^(2)-n)/2 = n + n^(2)-n = n^(2)
|
||||||
|
Average-Case: (n^(2)+n)/2
|
||||||
|
|
||||||
|
Big O => O(n^2)
|
||||||
*/
|
*/
|
||||||
package Assignments.A2;
|
package Assignments.A2;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user