mirror of
https://bitbucket.org/Mattrixwv/myhelpers.git
synced 2025-12-06 18:43:59 -05:00
Changed everything to bubbleSort because
quickSort was causing a stack overflow
This commit is contained in:
@@ -120,7 +120,7 @@ struct DynamicInt64Array getPrimes(int64_t goalNumber){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
quickSortDynamicInt64Array(&primes);
|
bubbleSortDynamicInt64Array(&primes);
|
||||||
return primes;
|
return primes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ struct DynamicInt64Array getNumPrimes(int64_t numberOfPrimes){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//The numbers should be in order, but sort them anyway just in case
|
//The numbers should be in order, but sort them anyway just in case
|
||||||
quickSortDynamicInt64Array(&primes);
|
bubbleSortDynamicInt64Array(&primes);
|
||||||
return primes;
|
return primes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +183,6 @@ struct DynamicInt64Array getFactors(int64_t goalNumber){
|
|||||||
++cnt;
|
++cnt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//If it didn't find any factors in the primes the number itself must be prime
|
//If it didn't find any factors in the primes the number itself must be prime
|
||||||
if(factors.size == 0){
|
if(factors.size == 0){
|
||||||
pushBackDynamicInt64Array(&factors, goalNumber);
|
pushBackDynamicInt64Array(&factors, goalNumber);
|
||||||
@@ -227,7 +226,7 @@ struct DynamicInt64Array getDivisors(int64_t num){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Sort the vector for neatness
|
//Sort the vector for neatness
|
||||||
quickSortDynamicInt64Array(&divisors);
|
bubbleSortDynamicInt64Array(&divisors);
|
||||||
|
|
||||||
//Return the vector of divisors
|
//Return the vector of divisors
|
||||||
return divisors;
|
return divisors;
|
||||||
|
|||||||
Reference in New Issue
Block a user