![EBK BUILDING JAVA PROGRAMS](https://www.bartleby.com/isbn_cover_images/9780134323718/9780134323718_largeCoverImage.jpg)
EBK BUILDING JAVA PROGRAMS
4th Edition
ISBN: 9780134323718
Author: Stepp
Publisher: PEARSON CUSTOM PUB.(CONSIGNMENT)
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 13.3, Problem 21SCP
Consider the following sorted array of integers. When a binary search is performed on this array for each of the following integer values, what indexes are examined in order? What result value is returned?
- a. 42
- b. 11
- c. 74
- d. 30
Expert Solution & Answer
![Check Mark](/static/check-mark.png)
Want to see the full answer?
Check out a sample textbook solution![Blurred answer](/static/blurred-answer.jpg)
Students have asked these similar questions
Consider the array:
42 88 4 889 972 4561 34
If these items are sorted into descending order by the MSD Radix Sort algoirthm, what is the resulting sequence of items?
(enter each number, separated by a comma; do not use any spaces or quotation marks)
a. What is the largest number of key comparisons made by binary search in searching for a key in the following array?
3 14 27 31 39 42 55 58 61 64 69 73 77 80 85 89 93 98
b. List all the keys of this array that will require the largest number of key comparisonswhen searched for by binary search.c. Find the average number of key comparisons made by binary search in a successful search in this array. Assume that each key is searched for with the same probability.d. Find the average number of key comparisons made by binary search in an unsuccessful search in this array. Assume that searches for keys in each of the 19 intervals formed by the array’s elements are equally likely.
What is the time complexity for the following code/program? 1.5 A binary search works like this: in a sorted array, the search algorithm compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value and repeating this until the target value is found. If the search ends with the remaining half being empty, the target is not in the array. What is the complexity of binary search? Why?
Chapter 13 Solutions
EBK BUILDING JAVA PROGRAMS
Ch. 13.1 - Describe two ways to search an unsorted array of...Ch. 13.1 - Prob. 2SCPCh. 13.1 - Prob. 3SCPCh. 13.1 - Prob. 4SCPCh. 13.1 - Prob. 5SCPCh. 13.1 - Prob. 6SCPCh. 13.1 - Prob. 7SCPCh. 13.1 - Prob. 8SCPCh. 13.2 - Prob. 9SCPCh. 13.2 - Prob. 10SCP
Ch. 13.2 - Prob. 11SCPCh. 13.2 - Prob. 12SCPCh. 13.2 - Prob. 13SCPCh. 13.2 - Prob. 14SCPCh. 13.2 - Prob. 15SCPCh. 13.3 - Prob. 16SCPCh. 13.3 - Prob. 17SCPCh. 13.3 - Prob. 18SCPCh. 13.3 - Prob. 19SCPCh. 13.3 - Prob. 20SCPCh. 13.3 - Consider the following sorted array of integers....Ch. 13.3 - Consider the following sorted array of integers....Ch. 13.3 - Prob. 23SCPCh. 13.3 - Prob. 24SCPCh. 13.3 - Prob. 25SCPCh. 13.4 - Prob. 26SCPCh. 13.4 - Prob. 27SCPCh. 13.4 - Prob. 28SCPCh. 13.4 - Prob. 29SCPCh. 13.4 - Prob. 30SCPCh. 13 - Prob. 1ECh. 13 - Prob. 2ECh. 13 - Prob. 3ECh. 13 - Prob. 4ECh. 13 - Prob. 5ECh. 13 - Prob. 6ECh. 13 - Prob. 7ECh. 13 - Prob. 8ECh. 13 - Prob. 9ECh. 13 - Prob. 10ECh. 13 - Prob. 11ECh. 13 - Prob. 12ECh. 13 - Prob. 13ECh. 13 - Prob. 14ECh. 13 - Prob. 15ECh. 13 - Prob. 16ECh. 13 - Prob. 17ECh. 13 - Prob. 18ECh. 13 - Prob. 19ECh. 13 - Prob. 20ECh. 13 - Prob. 21ECh. 13 - Prob. 1PPCh. 13 - Write a program that discovers all anagrams of all...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
A byte is made up of eight a. CPUs b. addresses c. variables d. bits
Starting Out with Java: From Control Structures through Objects (6th Edition)
Suppose that we create an array A of GameEntry objects, which has an integer scores field, and we clone A and s...
Data Structures and Algorithms in Java
Using your text editor, enter (that is, type in) the C++ program shown in Display 1.8. Be certain to type the f...
Problem Solving with C++ (10th Edition)
Run the hello, world program on your system. Experiment with leaving out parts of the program, to see what erro...
C Programming Language
Are reflex actions (such as flinching from a hot stove) rational? Are they intelligent?
Artificial Intelligence: A Modern Approach
Give a Java statement that will display a dialog window on the screen with the message I Love You.
Java: An Introduction to Problem Solving and Programming (8th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Quicksort SPLIT (the 2-pointer algorithm covered in class) is applied to the integer array [4,3,5,7,9,2,1], using the first entry as the pivot. Show the series of item swaps that are performed in the split process, and the array after each of these swaps, up to and including the step of placing the pivot at its correct location. You only need to show the split of the original array, you are not required to continue working on the subarrays after the split.arrow_forwardSorting 4. Consider the following array of int values. [17, 11, 6, 22, -3, 8, 4, 22, 2, 35, -4, 10] a. Write the contents of the array after 4 passes of the outermost loop of selection sort. Assume selection sort is sorting slots from low-to-high b. Write the contents of the array during each of the the recursive calls of merge sort.arrow_forwardAn array is a collection of similar data elements stored at contiguous memory locations. It is the simplest data structure where each data element can be accessed directly by only using its index number. The following is an array of unsorted numbers called NumArr. NumArr: 24 56 78 79 34 75 2 23 Given the above array, demonstrate how a binary search can be performed. Indicate all the necessary operations need to be performed using an algorithm or pseudocode.arrow_forward
- Use the following sorted array to answer the following questions: 1 3 4 7 8 10 11 1 2 3 5 7 11 13 17 19 23 29 31 What values (not index) are examined in what order when searching for 19 using binary search? For example, when it examines whether 1, 3, 5 and 19 are equal to 19, write down 1, 3, 5, 19.arrow_forwardConsider the following array of int values. [17, 11, 6, 22, -3, 8, 4, 22, 2, 35, -4, 10] Write the contents of the array after 4 passes of the outermost loop of selection sort. Assume selection sort is sorting slots from low-to-high Write the contents of the array during each of the the recursive calls of merge sort.arrow_forward3 7 1 7 9 4 5 8 1. Write down the steps of sorting the following array using Merge Sort. 2. Write down the steps of sorting the following array using Quick Sort.arrow_forward
- Part 1 1. Write a permutation of 9 integers which is not in sorted order. Sort the integers using the sorting algorithms: Bubble Sort, Insertion Sort, Selection Sort and Quick Sort. Assume that the numbers are stored in an array. You should show the contents of the array after each iteration for all the algorithms. 2. Suppose you are to sort elements which are stored in a very large sorted array followed by a relatively small number of "random" elements. Which of the sequential sorting algorithms from Part 1.1 would be especially suitable for such a task? Justify your choice. 3. What issues are significant when assessing the relative merits of different sorting algorithms? Compare and contrast the sorting algorithms with respect to these criteria.arrow_forwardFollowing is the function for interpolation search. This searching algorithm estimates the position (index) of a key in array based on the elements in the first position and last position in the array, and the length of array. The array must be sorted in ascending order. Suppose array A contains the following 15 elements: A = [1, 3, 3, 10, 17, 22, 22, 22, 24, 25, 26, 27, 27, 28, 28] At first iteration, at which position (index) the element of 24 is estimated in array A? In which part of array (starting index and ending index) the searching should continue? How many iterations the searching are performed until the element of 24 is found? int InterpolationSearch(int x[], int key, int n) { int mid, min = 0, max = n-1; while(x[min] < key && x[max] > key) { mid = min + ((key-x[min])*(max-min)) / (x[max]-x[min]); if(x[mid] < key) min = mid + 1; else if(x[mid] > key) max = mid - 1; else return mid; } if…arrow_forwardFill-in blank the correct term Deletion operation is .. .with arrays. Answer:arrow_forward
- A merge sort is used to sort an array of 1000 test scores in descending order. Which of the following statements is true?a) The sort is fastest if the original test scores are sorted from smallest to largestb) The sort is fastest if the original test scores are in completely sorted order.c) The sort is fastest if the original test scores are sorted from largest to smallest.d) The sort is the same, no matter what the order of the original elements.arrow_forwardSort the following array of numbers using counting sort and quick sort. Show all necessary steps of sorting in your run. [23,9,10,34,7,21,18,24,15]arrow_forwardConsider the algorithm for insertion sort shown below. The input to this algorithm is an array A. You must assume that indexing begins at 1.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License