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
Expert Solution & Answer
Chapter 30.5, Problem 30.5.1CP
Explanation of Solution
Purpose of given code:
The purpose of given code is to print resultant elements in array variable “values” with “IntStream” class using aggregate functions.
Explanation:
- The array variable “values[]” is declared and defined in type of “int” array.
- The value “10” is printed because the “IntStream” operation adds all values in array “values[]”...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write 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 table
For an fstream object A, whose data elements are of type B and a local variable called C, the proper way to read in one element of type B element from A into C is:
What is the return type for the method readObject of the classObjectInputStream?
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
- 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_forwardHello 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, Emmanuelarrow_forwardPlease answer it in Python Write a function pairsbypairslist that would return pair by pair from the smallest value to the biggest value For example [12, 13, 11, 15], # return : (11, 12) and (13, 15) [9, 15, 4, 24, 19, 2] # return : (2,4) (9,15) (19,24) [1, 5, 9, 15, 21, 9, 12, 9], # return : (1,5) (9,9) (9,12) (15,21)arrow_forward
- In Python, The function concatAltChars takes a string parameter s and a boolean parameter even; the function concatenates together either the even-position characters of s or the odd-position characters of s, depending on whether even is True, or False, respectively. The accumulated string is returned. For example, the even-indexed characters of "HANOVER" are at indexes 0, 2, 4, and 6: H N V R. So, concatAltChars("HANOVER", True) returns the string result "HNVR". But concatAltChars("HANOVER", False) returns the string result "AOE". For example: Test Result s = "goldfinches" print(concatAltChars(s, True)) glfnhs s = "A" print(concatAltChars(s, True)) A s = "A" print(concatAltChars(s, False))arrow_forwardvoid 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 MIPSarrow_forwardWrite a program that animates quadratic probing,as shown in Figure . You can change the initial size of the hash-table in theprogram. Assume the load-factor threshold to be 0.8.arrow_forward
- Write 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_forwardRequirements: Please do this in Java Programming Please show screenshots of your work. 10. Write method public static int binarySearch(int[] arr, int target) that return an index of one match of target in arr. If there is no match, return -1. 11. Write a nested for loop statement to print out the multiplication table for numbers 1, 2, .., 9. The output should looks like: 1 x 1 = 1, 1 x 2 = 2, 1 x 3 = 3, 1 x 4 = 4, 1 x 5 = 5, 1 x 6 = 6, 1 x 7 = 7, 1 x 8 = 8, 1 x 9 = 9 2 x 2 = 4, 2 x 3 = 6, .................................................................................., 2 x 9 = 18 3 x 3 = 9, .................................................................................., 3 x 9 = 27 .................................................................................................... 9 x 9 = 81 (Hint: Use System.out.printf to get columns alignment nice and neat) 12. Write a method public static initializeArray(int [] arr) to initialize a given int array named arr with random…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
- This is supposed to test your understanding of Java streams and lambda expressions. Specifically how to create a nonparallel and parallel stream. Intermediate operations, such as map, flatMap, and filter. The terminal operation collect. How to work with java lambda functions with these operations. And efficient programming. This assignment is not meant to be exhausting, in the ideal situation, you will only have to write 25 lines of code to complete this entire assignment. You are to fill in the code in the StreamsHomeWork.java file. You may find a description of what is to be performed for each function below or in that java file provided. Please keep in mind that all the functions have a timelimit in the milliseconds, the exact time for each function is documented below. Please fill in the functional code in the StreamsHomeWork.java file and submit the StreamsHomeWork.java file to Grader Than. Note: The last two functions of the assignment can be used to help you select winning…arrow_forwardGiven 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_forwardThis question is in Java. We are required to map over some data and incement by 10. import.java.util.stream.Collectors; import.java.util.stream.Stream public class IncrementTheData implements Assignment {public Object solution(ArrayList<Integer> nums) { Stream.of(1,2,3,4,5,6) .map(not sure what would go in here) .collectors(Collectors.toList())return null;}} //So this is as far as I got with this question. The instructions are vague but I think I'm on the right track. Am I?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