Question: java programming 18. Search Benchmarks Modify the sequentialSearch and binarysearch methods presented in this chapter so they keep a count of and display on the
java programming


18. Search Benchmarks Modify the sequentialSearch and binarysearch methods presented in this chapter so they keep a count of and display on the screen the number of comparisons they make before finding the value they are searching for. Then write a program that has an array of at least 20 integers. It should call the sequentialsearch method to locate at least five of the values. Then it should call the binarysearch method to locate the same values. On average, which method makes the fewest comparisons? 20. Lo Shu Magic Square The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown in Figure 7-32. The Lo Shu Magic Square has the following properties: . The grid contains the numbers 1 through 9 exactly .The sum of each row, each column, and each diagonal all add up to the same number. This is shown in Figure 7-33. In a program you can simulate a magic square using a two-dimensional array. Write a method that accepts a two-dimensional array as an argument and determines whether the Figure 7-32 Lo Shu Magic Square 3 5 7 8 6 Flgure 7-33 Row, column, and diagonal sums in the lo Shu Magic Square 15 215 15 15 15 15 15
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
