Started Big O Analysis.

This commit is contained in:
Jonathan Turner 2024-02-22 22:12:21 -05:00
parent 456c003159
commit 9d87b9924f

View File

@ -50,6 +50,19 @@ Algorithm Design Block
Big-O Analysis: (Based on Implementation) Big-O Analysis: (Based on Implementation)
n = the number of elements in the set.
k = the number of elements in the subset.
| init Comps | init values | i | totalSum | generateSubsets | subset | value | subsetTotal | if(half) | asignSet | secondSubset | printResults |
---------------------------------------------------------------------------------------------------------------------min--max---------------------
| 1 | 1 | 1 | 1 | 2^n | 1 | 2^(n)+1 | 2^(n)+1 | 2^(n) | 0 1 |
| | | 2 | 1 | | 2 | 2^(n)+2 | 2^(n)+2 | 2^(n) | |
| | | 3 | 1 | | 3 | 2^(n)+3 | 2^(n)+3 | 2^(n) | |
| | | 4 | 1 | | 4 | 2^(n)+4 | 2^(n)+4 | 2^(n) | |
| | | ... | ... | | ... | ... | ... | 2^(n) | |
| | | n | 1 | | 2^n | 2^(n)+k | 2^(n)+k | 2^(n) | |
--------------------------------------------------------------------------------------------------------------------------------------------------
| 1 | 1 | X | n | 2^n | X | X | | |
Best-Case Scenario: Best-Case Scenario:
Worse-Case Scenario: Worse-Case Scenario:
Average-Case: Average-Case:
@ -239,6 +252,12 @@ public class Partition {
List<Integer> firstSubset = null; List<Integer> firstSubset = null;
List<Integer> secondSubset = null; List<Integer> secondSubset = null;
/* If the total is odd, there cannot be equal disjoint subsets. */
if (totalSum % 2 == 1) {
printResults(firstSubset, secondSubset);
return;
}
/* /*
* Checks through every subset that was generated, * Checks through every subset that was generated,
* if a subset is found it sets the firstSubset to the found subset. * if a subset is found it sets the firstSubset to the found subset.