Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 30.3, Problem 30.3.1CP
Program Plan Intro
Purpose of given code:
Purpose of given code is to implements the aggregate operations for “IntStream”, “LongStream”, and “DoubleStream” for processing primitive “int”, “long”, and “double” values.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Consider a text file of names, with one name per line, that has been compiled from several different sources. A sample is shown below:Brooke TroutDinah SoarsJed DyeBrooke TroutJed DyePaige TurnerThere are duplicate names in the file. We would like to generate aninvitation list but don’t want to send multiple invitations to the sameperson. Write a program that eliminates the duplicate names by usinga HashSet. Read each name from the file, add it to the HashSet, andthen output all names in the HashSet to generate the invitation listwithout duplicates
Hello
The java function belw is generating a NullPointerException. How can I improve it?
public int quadraticProbing(String[] hashArray, int initial_index, int collision) {
int index = (initial_index + (collisions * collisions)) % maxSize;
System.out.println("Index " + index);
if (index == maxSize) {
System.out.println("flag 04");
index = 0; // To wrap around the table
}
if (hashArray[index] == null) {
return index; // We can insert at this location
} else {
// The index isn't empty so we need to insert the value
// at the end of the list
}
collisions = ++collision;
return quadraticProbing(hashArray, initial_index, collision); // Recursive call
}
Thanks in advance.
Respectfully,
Emmanuel
void radixSort(int arr[], int n)
{
intm=getMax(arr, n);
for (intexp=1; m/exp>0; exp*=10)
countSort(arr, n, exp);
}
void printData(int arr[], int start, int len)
{
if( start>=len )
return( 0 );
printf("%d\n", arr[start]);
printData(arr, start+1, len);
}
int main()
{
intarr[]= {8, 9, 3, 4, 7, 2, 5, 6, 1};
intn=sizeof(arr) /sizeof(arr[0]);
radixSort(arr, n);
printData(arr, 0, n);
return0;
}
In MIPS
Chapter 30 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 30.1 - Prob. 30.1.1CPCh. 30.2 - Prob. 30.2.1CPCh. 30.2 - Prob. 30.2.2CPCh. 30.2 - Prob. 30.2.3CPCh. 30.2 - Prob. 30.2.4CPCh. 30.3 - Prob. 30.3.1CPCh. 30.3 - Prob. 30.3.2CPCh. 30.3 - Prob. 30.3.3CPCh. 30.3 - Prob. 30.3.4CPCh. 30.3 - Given an array names in Listing 30.1, write the...
Ch. 30.4 - Prob. 30.4.1CPCh. 30.4 - How do you create a parallel stream?Ch. 30.4 - Prob. 30.4.3CPCh. 30.4 - Prob. 30.4.4CPCh. 30.4 - Prob. 30.4.5CPCh. 30.4 - Write a statement to obtain an array of 1000...Ch. 30.5 - Prob. 30.5.1CPCh. 30.5 - Prob. 30.5.2CPCh. 30.5 - Prob. 30.5.3CPCh. 30.5 - Prob. 30.5.4CPCh. 30.6 - Prob. 30.6.1CPCh. 30.7 - Prob. 30.7.1CPCh. 30.8 - Can the following code be used to replace line 19...Ch. 30.8 - Prob. 30.8.2CPCh. 30.8 - Prob. 30.8.3CPCh. 30.8 - Prob. 30.8.4CPCh. 30.8 - Write the code to obtain a one-dimensional array...Ch. 30 - Prob. 30.1PECh. 30 - Prob. 30.2PECh. 30 - Prob. 30.3PECh. 30 - (Print distinct numbers) Rewrite Programming...Ch. 30 - Prob. 30.5PECh. 30 - Prob. 30.6PECh. 30 - Prob. 30.7PECh. 30 - Prob. 30.8PECh. 30 - Prob. 30.9PECh. 30 - Prob. 30.10PECh. 30 - Prob. 30.11PECh. 30 - (Sum the digits in an integer) Rewrite Programming...Ch. 30 - (Count the letters in a string) Rewrite...Ch. 30 - Prob. 30.14PECh. 30 - (Display words in ascending alphabetical order)...Ch. 30 - Prob. 30.16PECh. 30 - Prob. 30.17PECh. 30 - (Count the occurrences of words in a text file)...Ch. 30 - (Summary information) Suppose the file test.txt...
Knowledge Booster
Similar questions
- Given the following Java functions, transcribe it into a Python 3 program. /* Each entry stores a (key, value) pair, it's hash value and* a reference to the next entry with the same hash value */class Entry {Object key;Object value;final int hash;Entry next; /*** Create new entry.*/Entry(int h, Object k, Object v, Entry n) {value = v;next = n;key = k;hash = h;}}arrow_forwardCreate a program that accepts a string as input, an integer k as a command-line argument, and outputs a sorted collection of all the k-grams it located, each followed by its index within the string.arrow_forwardvoid ExtractMinimumWeightPath(int path[MAX], int weights[MAX][MAX], int pathWeights[MAX][MAX], int rowc, int colc){int rowsCount = rowc;int colsCount = colc;path[rowsCount];int col = 0;int i = 0;for(i=1;i<colsCount;i++){if(pathWeights[rowsCount-1][i]<pathWeights[rowsCount-1][col]){col = i;}} int row = rowsCount-1;do{path[row] = col + 1;if (col>0 && pathWeights[row-1][col-1] + weights[row][col] == pathWeights[row][col]){col = col - 1;} else if (col < colsCount-1 && pathWeights[row-1][col+1] + weights[row][col] == pathWeights[row][col]){col = col + 1;}row--;} while(row>0);path[0] = col + 1;} This is a code in C, I need to change the code as much as possible, but on condition to perform the same work as this. Changing the var names and the loops is enougharrow_forward
- Given the following Java functions, transcribe it into a Python 3 program. /*** Add a new entry with the specified key, value and hash code to* the specified bucket. It is the responsibility of this* method to resize the table if appropriate.*/void addEntry(int hash, Object key, Object value, int bucketIndex) {table[bucketIndex] = new Entry(hash, key, value, table[bucketIndex]);if (size++ >= threshold)resize(2 * table.length);}arrow_forwardWrite a program that uses a HashMap to compute a histogram of positivenumbers entered by the user. The HashMap’s key should be the numberthat is entered, and the value should be a counter of the number of timesthe key has been entered so far. Use −1 as a sentinel value to signal theend of user input. For example, if the user inputs:512355321-1then the program should output the following (not necessarily in this order):The number 3 occurs 2 times.The number 5 occurs 3 times.The number 12 occurs 1 times.The number 21 occurs 1 times.arrow_forwardWrite a program that obtains the executiontime of external sorts for integers of size 6,000,000, 12,000,000, 18,000,000,24,000,000, 30,000,000, and 36,000,000. Your program should print a tablelike this:arrow_forward
- Write a BinarySearch client that takes an int value T as command-line argument and runs T trials of the following experiment for N = 103, 104, 105, and 106: generate two arrays of N randomly generated positive six-digit int values, and find the number of values that appear in both arrays. Print a table giving the average value of this quantity over the T trials for each value of N.arrow_forwardWrite a program that benchmarks QuickSort and InsertionSort. You should use at least 5 different data sets and record the performance of each algorithm on the same sets under the same conditions. Write a short report that compares the two algorithms based your results. It is important to include a discussion of the initial states of the data sets in your report. language Java public class week3 {public static void main(String args[]){ //========================================================== //Question 1 testing //================== // Comment on benchmarking for Q1 results // // //========================================================== } static void quickSort(int f[], int p, int q){ if(q-p <= 1) ; //skip else{ int x; int i, j, k; // let x = middle element in f[p..q-1] x = f[(p+q)/2]; //x = f[p]; i = p; j = p; k = q; while(j != k){ if(f[j] == x) j = j + 1; else if(f[j] < x){ //swap f[j] with f[i] int temp; temp = f[j]; f[j] = f[i]; f[i] = temp; j = j + 1; i = i + 1; } else{…arrow_forwardStack CreateStack(S) push (S, 10) push (S, 15) push (S, 20) x = top (S) push (S, x + 5) x = pop (S) + top (S) push (S, x – pop (S)) push (S, pop (pop (S))) push (S, x – top (S)) push (S, push(S, x) – top (S)) After executing the given codes above, answer the questions and explain. Thanksarrow_forward
- PLEASE ONLY ANSWER IN POWERSHELL LANGUAGE Write a script in the VS Code environment that prompts your for a number which should be between 4 and 9. Loop to generate that number of random hashtables and add these hashtables into an array. The result is an array of hashtable objects. Use the .getType() method to verify this both for the array and for the last element of your array.arrow_forwardWrite a program in C/C++ that reads N number of nonnegative decimal numbers from a user and creates a hash table to store the numbers. The output of the program displays the order of the numbers in the hash table. The program then prompts the user to enter a target value. The program searches the target value to the hash table, and displays the search outcome. For simplicity, let’s assume that N = 6 and the size of the hash table is 10. Use this hash function in your code h(k) = 2k+3 where k is the key value. Use linear probe method for collision resolution. Example test run Test Run 1: Enter 6 elements: 3 2 9 6 11 13 Hash table order: 13 9 - - - 6 11 2 - 3 Enter the target: 1111 is located at index: 6 Test Run 2: Enter 6 elements: 3 2 9 6 11 13 Hash table order: 13 9 - - - 6 11 2 - 3 Enter the target: 1515 is not in the tablearrow_forwardImprove the given code below, make sure that the code will require input from the user. Problem: Write a JavaScript function that would accept a string and returns its letters in alphabetical order. function alpha(str){let res;var arr = str.split(""); //splits the strres = arr.sort().join(""); //sorts arr && forms to a strreturn res;}console.log("Num5");console.log(alpha("CSIT201"));arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education