Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 16.2, Problem 16.6CP
Program Plan Intro
Sequential search:
- The sequential search
algorithm is the process to find an item in an array. - It compares each value and searching starts at the beginning of the array.
- In the searching process, the algorithm compares each item in an array and finds an item.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The element being searched for is not in an array of 100 elements. What is the maximum number of comparisons needed in a sequential search to determine that the element is not there if the elements are completely unsorted?
You are given 4 items as {value, wveightpairs in this format ({20, 5}, {60, 20}, {25, 10},{X,25}}You can assume that the array is sorted based on the
capacity of knapsack is 50. The item no. 4 (whose weightis 25 ) is taken fractionally to fill upto the knapsack capacity. That fraction is represented in format. What is the
ratio. The
lowest possible value of b?
For the question above, assume the total value stored in the knapsack is 135 after you have filled upto the knapsack capacity. What is the value of X(in other words, the valueo
the item no. 4)?
Give your arSwer to at least two decimal places
Consider the following list: L = 387, 690, 234, 435, 567, 123, 441. The number of components n = 7, the number of numbers l = 3, and the radix r = 10 are used here. This indicates that radix sort would require 10 bins and would arrange in three passes.
demonstrates the radix sort passes over the array. It is believed that each key is tossed face down into the bin. When the keys are gathered in order from each bin at the conclusion of each run, the list of keys in each bin is flipped upside down and added to the output list.
Chapter 16 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 16.1 - Prob. 16.1CPCh. 16.1 - Prob. 16.2CPCh. 16.1 - Prob. 16.3CPCh. 16.1 - Prob. 16.4CPCh. 16.2 - Prob. 16.5CPCh. 16.2 - Prob. 16.6CPCh. 16.2 - Prob. 16.7CPCh. 16.2 - If a sequential search is performed on an array,...Ch. 16.3 - Prob. 16.9CPCh. 16.3 - Prob. 16.10CP
Ch. 16.3 - Prob. 16.11CPCh. 16.3 - Prob. 16.12CPCh. 16.3 - Prob. 16.13CPCh. 16.3 - Prob. 16.14CPCh. 16.3 - Let a[ ] and b[ ] be two integer arrays of size n....Ch. 16.3 - Prob. 16.16CPCh. 16.3 - Prob. 16.17CPCh. 16.3 - Prob. 16.18CPCh. 16 - Prob. 1MCCh. 16 - Prob. 2MCCh. 16 - Prob. 3MCCh. 16 - Prob. 4MCCh. 16 - Prob. 5MCCh. 16 - Prob. 6MCCh. 16 - Prob. 7MCCh. 16 - Prob. 8MCCh. 16 - Prob. 9MCCh. 16 - Prob. 10MCCh. 16 - True or False: If data is sorted in ascending...Ch. 16 - True or False: If data is sorted in descending...Ch. 16 - Prob. 13TFCh. 16 - Prob. 14TFCh. 16 - Assume this code is using the IntBinarySearcher...Ch. 16 - Prob. 1AWCh. 16 - Prob. 1SACh. 16 - Prob. 2SACh. 16 - Prob. 3SACh. 16 - Prob. 4SACh. 16 - Prob. 5SACh. 16 - Prob. 6SACh. 16 - Prob. 7SACh. 16 - Prob. 8SACh. 16 - Prob. 1PCCh. 16 - Sorting Objects with the Quicksort Algorithm The...Ch. 16 - Prob. 3PCCh. 16 - Charge Account Validation Create a class with a...Ch. 16 - Charge Account Validation Modification Modify the...Ch. 16 - Search Benchmarks Write an application that has an...Ch. 16 - Prob. 8PCCh. 16 - Efficient Computation of Fibonacci Numbers Modify...
Knowledge Booster
Similar questions
- Answer not any previously answer. Please different code stamp.arrow_forwardRandomized quicksort compares individual pairs of elements but it does not necessarily compare every element to every other element. When the input is the array [2, 9, 5, 4, 6], what is the probability that randomized quicksort compares 2 and 4 directly to each other? Give an exact answer.arrow_forwardYou are given 4 items as (value, weightpairs in this format {{20, 5), (60, 20), (25, 10), (X, 25}}You can assume that the array is sorted based on the ratio. The capacity of knapsack is 50. The item no. 4 (whose weights 25) is taken fractionally to fill upto the knapsack capacity. That fraction is represented in format. What is the lowest possible value of ? weightarrow_forward
- Given a random array, please design an algorithm to find the median. First describe your algorithm, and then simulate your algorithm on the following array: {14, 2, 15, 1, 6, 30, 9, 7, 8, 11}.arrow_forwardSuppose you have to search a key element from a list of array using divide and conquertechnique, then which searching method is appropriate to use? Write the best case and worstcase time complexity for the identified search.arrow_forwardusing selection sort algorithm, the intermediate sorting results of sorting the array (1,3,24,19,5,2} in Descending order are: starting: {12,4,25,20,6,3,100} Result of the first iteration: Result of the second iteration: Result of the third iteration: Result of the fourth iteration: { Result of the fifth iteration:arrow_forward
- The algorithm: –In an array of n elements, go to index [n/2] –If the record there is the one you want, you are done –If the record value there is smaller than your search value, all records less than the current record can be ignored – set your search range of elements to [n/2+1…n] and return to step 1 –Otherwise, set your range of elements to [0…(n/2)-1] and return to step 1 –Repeat this loop until you have 0 elements (record is not found) or record is found Short answer Another approach to the update algorithm is to perform use the delete function for the old value and if it is successful, call the insert function using the new value. Explain in your own words if you think this approach is significantly better, worse, or in the same category as the algorithm discussed in the slides, and why.arrow_forwardSuppose you wanted to use a linear search on a sorted data set. What would be the average number of comparisons to find a given element? Why?arrow_forwardSuppose you have the following sorted list [3, 5, 6, 8, 11, 12, 14, 15, 17, 18] and are using the binary search algorithm. Which group of numbers correctly shows the sequence of comparisons used to find the key 8? If the array/subarray has even length, there is two choices for the middle element. In this case, choose the left one, i.e., a, b, c, d, then middle element is b. O 11, 5, 6, 8 О 14, 12, 11, 8 О 12, 6, 5, 8 О 18, 12, 6, 8 О 3, 5, 6, 8arrow_forward
- Given an 8-element array: A = {x1, X2, X3, X4, X5, X6, 7, x8}, we would like to find its 3rd smallest element. It is known that x₁ and 8 are the two extreme elements: max and min, but we do not know which one is the max and which one is the min. It is also known that x4 and x5 are the two medians: left-median and right-median. What is the minimum number of comparisons you need to find the 3rd smallest element of the original array? Ans:arrow_forwardFor selection sort, how many comparisons would be needed to sort an array containing 100 elements if the original array elements were already sorted? What if the original array elements were sorted in reverse order? What if the original array elements were all identical?arrow_forwardWhen using array resizing, the size of the table is alwaysa power of 2. Isn’t that a potential problem, because it onlyuses the least significant bits of hashCode()?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