Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/edu/allegheny/expose/BigOh.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void setCompClass(ComplexityClass compClass) {

this.compClass = compClass;

if (compClass == ComplexityClass.QUADRADIC)
if (compClass == ComplexityClass.QUADRATIC) // changed "QUADRADIC"to "QUADRATIC"
exponent = 2;
else if (compClass == ComplexityClass.CUBIC)
exponent = 3;
Expand Down Expand Up @@ -70,7 +70,7 @@ public String toString(){
else
return compClass.toString();
}

public boolean equals(BigOh o){
if (o.compClass == this.compClass && o.exponent == this.exponent){
return true;
Expand All @@ -80,5 +80,3 @@ public boolean equals(BigOh o){
}

}


2 changes: 1 addition & 1 deletion src/edu/allegheny/expose/ComplexityClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public enum ComplexityClass{
LOGARITHMIC,
LINEAR,
LINEARITHMIC,
QUADRADIC,
QUADRATIC, // changed "QUADRADIC"to "QUADRATIC"
CUBIC,
POWER,
EXPONENTIAL;
Expand Down
24 changes: 12 additions & 12 deletions src/edu/allegheny/expose/ReverseEngineer.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public class ReverseEngineer{
* It will have already been sorted by times doubled
*/
private ExperimentResults data;

/**
* Data aggregated by times doubled
*/
private List<Double[]> avg;

/**
* Percentage that min / max of a dataset must be within to be considered
* Percentage that min / max of a dataset must be within to be considered
* consistant
*/
private static double spreadTolerance = .10;
Expand Down Expand Up @@ -75,7 +75,7 @@ public void loadData(String fileName){
data.readCSV(fileName);
}


/**
* Analyze the results of a doubling experiment.
* @return BigOh determined from data
Expand Down Expand Up @@ -105,7 +105,7 @@ public BigOh analyzeData(){

BigOh result = new BigOh();

// now in the case of N^0 or N^1, get more specific
// now in the case of N^0 or N^1, get more specific
if ( exp == 0 ){
// check for constant time
if (checkConstant()){
Expand All @@ -120,7 +120,7 @@ public BigOh analyzeData(){
result.setCompClass(ComplexityClass.LINEARITHMIC);
}
}else if (exp == 2){
result.setCompClass(ComplexityClass.QUADRADIC);
result.setCompClass(ComplexityClass.QUADRATIC); // changed "QUADRADIC"to "QUADRATIC"
}else if (exp == 3){
result.setCompClass(ComplexityClass.CUBIC);
}else{
Expand Down Expand Up @@ -167,7 +167,7 @@ protected boolean checkWithinRange(double[] input, double tolerance){
* @return true if the data is deemed O(n)
*/
protected boolean checkConstant(){

aggregate();

// fetch last 3 elements
Expand All @@ -182,7 +182,7 @@ protected boolean checkConstant(){
* @return true if the data is deemed O(nlog(n))
*/
protected boolean checkLinear(){

aggregate();

// fetch last 3 elements
Expand All @@ -191,13 +191,13 @@ protected boolean checkLinear(){
// divide by n
double[] div = {last[0] / 4, last[1] / 2, last[2] };

// check to see that these values are within tolerance of each other
// check to see that these values are within tolerance of each other
return checkWithinRange(div, spreadTolerance);

}









}
4 changes: 2 additions & 2 deletions src/edu/allegheny/expose/ReverseEngineerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void testWBubble(){
eng.loadData("tests/bubblesort.csv");
BigOh res = eng.analyzeData();
ComplexityClass ans = res.getCompClass();
Assert.assertEquals(ans, ComplexityClass.QUADRADIC);
Assert.assertEquals(ans, ComplexityClass.QUADRATIC); // changed "QUADRADIC"to "QUADRATIC"
}


Expand Down Expand Up @@ -55,5 +55,5 @@ public void testWLinear(){
Assert.assertEquals(ans, ComplexityClass.LINEAR);
}


}
12 changes: 12 additions & 0 deletions src/edu/allegheny/expose/examples/sort/SortingExperiment.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ public static void main(String[] args){
SortingExperiment exp = new SortingExperiment(nargs);
exp.name = args[0];

boolean validAlg = false; // input assumed to be invalid algorithm
for (int i = 0; i < algs.length; i++) { // for each valid algorithm option...
if (algs[i].equals(exp.name)) { // check if input equals valid algorithm option
validAlg = true; // true when input matches at least one valid algorithm
}
}
if (!validAlg) { // if input is invalid...
System.out.println("Sorry, that is not a valid \"Sorting\" algorithm.");
System.out.println("Supported algorithms are: " + Arrays.toString(algs));
return; // exit main method
}

switch (exp.name){
case "quick":
exp.alg = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

public class SortingExperimentRepeated{

private static final BigOh quadratic = new BigOh(ComplexityClass.QUADRADIC);
private static final BigOh quadratic = new BigOh(ComplexityClass.QUADRATIC); // changed "QUADRADIC"to "QUADRATIC"
private static final BigOh linearithmic = new BigOh(ComplexityClass.LINEARITHMIC);


public static void main(String[] args){

int experiments = 0;
int correct = 0;

for (int count = 0; count < Integer.parseInt(args[0]); count++){


for (String a : SortingExperiment.algs) {
BigOh ans = SortingExperiment.doubleExp(a);
Expand Down
12 changes: 12 additions & 0 deletions src/edu/allegheny/expose/examples/unique/UniqueExperiment.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ public static void main(String[] args) {
UniqueExperiment exp = new UniqueExperiment(nargs);
exp.name = args[0];

boolean validAlg = false; // input assumed to be invalid algorithm
for (int i = 0; i < algs.length; i++) { // for each valid algorithm option...
if (algs[i].equals(exp.name)) { // check if input equals valid algorithm option
validAlg = true; // true when input matches at least one valid algorithm
}
}
if (!validAlg) { // if input is invalid...
System.out.println("Sorry, that is not a valid \"Unique\" algorithm.");
System.out.println("Supported algorithms are: " + Arrays.toString(algs));
return; // exit main method
}

switch (exp.name) {
case "unique1":
exp.alg = 1;
Expand Down