jimthecanadian
IS-IT--Management
I am writing an assignment for school and I have run into a glitch. My program generates a stack overflow as soon as it runs the constructor for the object i am creating. The program does use recursion but it never gets to the recursive call (and it is not very deeply recursed anyway). Can anyone give me an idea of where to look?
here are the variables and constructor. For any value larger that 20 or so i get the overflow error.
here are the variables and constructor. For any value larger that 20 or so i get the overflow error.
Code:
public class deterministicSelect {
int[] randomArray; //array to be selected
int arraySize; // size of above
int spatializer = 200; // ratio to increase array size by for random number generation
int[] arrayOfMedians = new int[400];
Random ranGen = new Random(); // Random number generator
PriorityQueue<Integer> distinct = new PriorityQueue<Integer>(); // heap to track distinct elements in number generation
//-------------------------------------------------------------------------------------------
// Constructor --
//-------------------------------------------------------------------------------------------
public deterministicSelect(int n){
randomArray = new int[n]; // instantiate array to size n
arrayOfMedians = new int[n/5+1];
arraySize = n; // easier than writing randomArray.length() all the time
fillRandomArray(); // function to fill array with distinct random numbers
}