A hash table of length 10 uses open addressing with hash fun…
A hash table of length 10 uses open addressing with hash function h(k) = k % 10, and quadratic probing. After inserting 4 values into an empty hash table, the table is as shown below. 0 1 2 42 3 23 4 5 55 6 66 7 8 9 At what index value 12 will be inserted?
Read DetailsA hash table of length 10 uses open addressing with hash fun…
A hash table of length 10 uses open addressing with hash function h(k) = k % 10, and separate chaining. After inserting several values into an empty hash table, the table is as shown below. 0 1 2 42 3 23 4 5 55 6 46 7 8 9 At what index will the value 12 be inserted?
Read DetailsConsider the following array: 3, 56, 24, 5, 39, 4, 27, 1 Con…
Consider the following array: 3, 56, 24, 5, 39, 4, 27, 1 Consider the algorithm described in class that turns the above array into a min heap. Answer the following two questions: [1] How many times do two numbers swap locations in the array? [2] What number is stored in slot/index 4 after the array is turned into a min heap?
Read DetailsConsider the following function: public static void func1(d…
Consider the following function: public static void func1(double[] real, double[] imag) { int n = real.length; if (n > 1){ double[] evenReal = new double[n / 2]; double[] evenImag = new double[n / 2]; double[] oddReal = new double[n / 2]; double[] oddImag = new double[n / 2]; for(int i = 0; i < n / 2; i++){ evenReal[ i ] = real[2 * i]; evenImag[ i ] = imag[2 * i]; oddReal[ i ] = real[2 * i + 1]; oddImag[ i ] = imag[2 * i + 1]; } func1(evenReal, evenImag); func1(oddReal, oddImag); for(int k = 0; k < n / 2; k++){ double tReal = Math.cos(-2 * Math.PI * k / n) * oddReal[ k ] - Math.sin(-2 * Math.PI * k / n) * oddImag[ k ]; double tImag = Math.sin(-2 * Math.PI * k / n) * oddReal[ k ] + Math.cos(-2 * Math.PI * k / n) * oddImag[ k ]; real[ k ] = evenReal[ k ] + tReal; imag[ k ] = evenImag[ k ] + tImag; real[k + n / 2] = evenReal[ k ] - tReal; imag[k + n / 2] = evenImag[ k ] - tImag; } } } Provide the recurrence relation for the code in terms of R(n) = [A] * R([B]) + O([C]). When finished, provide the overall [Runtime] of the function. Do not put any spaces in your answers and do not capitalize anything. If your answer is n^2, put in n^2, not n ^ 2. Similarly, if your answer is n*log(n), put in exactly n*log(n), do not put in n * log (N).
Read DetailsAssume the following Sport class has already been written:…
Assume the following Sport class has already been written: public class Sport { private String name; private int numPlayers; public Sport(String name, int numPlayers) { this.name = name; this.numPlayers = numPlayers; } public String getName() { return name; } public int getNumPlayers() { return numPlayers; } public String toString() { return “Sport: ” + name + “, Number of Players: ” + numPlayers; }} A TeamSport contains 4 things: a name, numPlayers, numTeams and duration. The name is a String and the other 3 are ints. You must create the TeamSport class. The following “main” method must work correctly given your TeamSport class. public static void main(String[] args) { TeamSport[] teamSports = { new TeamSport(“Soccer”, 11, 20, 95), new TeamSport(“Basketball”, 5, 30, 48), new TeamSport(“Hockey”, 6, 32, 60), new TeamSport(“Football”, 11, 32, 60) }; // Passed in as name, numPlayers, numTeams and then duration. teamSports[0].setDuration(90); System.out.println(teamSports[1].getNumberTeams()); // Prints out 30 System.out.println(teamSports[2].getName()); // Prints out exactly this: Sport is Hockey Arrays.sort(teamSports); // TeamSports with the shortest duration are first. // If there is a tie with duration, then the team with the smallest number of players is first. for (TeamSport teamSport : teamSports) { System.out.println(teamSport); }} When the teamSport is printed out for the Soccer item, the string that prints out is exactly the following: Number of Teams: 2, Duration: 90 minutes, Sport: Soccer, Number of Players: 11 Some things to note with your code: You must only include the methods needed for the main method to work. Do not include extra methods in your TeamSport class. Your TeamSport class must use inheritance and interfaces well. In other words, you should have no redundant code in your TeamSport class.
Read Details