Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
5th Edition
ISBN: 9780134801155
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 9.4, Problem 9.5CP
On average, with an array of 1,000 elements, how many comparisons will a sequential search perform? {Assume the items being searched for are consistently found in the array.)
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Question 8
Sort the following numbers using an "in place" version of a selection sort. This
means that you should have only one array throughout and all elements should be
present at all times. Show each "pass" of the algorithm.
34, 25, 11, 44, 21, 8, 4, 28, 16, 31
weight
You 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 value ratio. 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 informat. What is the
lowest possible value of 6?
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 value of
the item no. 4) ?
Give your answer to at least two decimal places.
List all the steps used to search for 18 in the sequence 1, 2, 4, 8, 10, 12, 18, 20, 22. Be sure to show EVERY step.
A. linear search
B. binary search
Use the following array and indices in your answer:
Array:
1
2
4
8
10
12
18
20
22
Index:
1
2
3
4
5
6
7
8
9
Chapter 9 Solutions
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Ch. 9.3 - Which of the sorting algorithms discussed makes...Ch. 9.3 - Prob. 9.2CPCh. 9.3 - Prob. 9.3CPCh. 9.4 - Prob. 9.4CPCh. 9.4 - On average, with an array of 1,000 elements, how...Ch. 9.4 - Prob. 9.6CPCh. 9 - Prob. 1MCCh. 9 - Prob. 2MCCh. 9 - Prob. 3MCCh. 9 - Prob. 4MC
Ch. 9 - Prob. 5MCCh. 9 - Prob. 6MCCh. 9 - Prob. 7MCCh. 9 - Prob. 8MCCh. 9 - Prob. 9MCCh. 9 - Prob. 10MCCh. 9 - Prob. 1TFCh. 9 - Prob. 2TFCh. 9 - Prob. 3TFCh. 9 - Prob. 4TFCh. 9 - Prob. 5TFCh. 9 - Prob. 1AWCh. 9 - Prob. 2AWCh. 9 - Prob. 3AWCh. 9 - What algorithm does the following pseudocode...Ch. 9 - Prob. 1SACh. 9 - Prob. 2SACh. 9 - Prob. 3SACh. 9 - Prob. 4SACh. 9 - Prob. 5SACh. 9 - Why is the selection sort more efficient than the...Ch. 9 - Prob. 7SACh. 9 - Prob. 8SACh. 9 - Assume the following main module is in a program...Ch. 9 - Prob. 1PECh. 9 - Sorted Names Design a program that allows the user...Ch. 9 - Rainfall Program Modification Recall that...Ch. 9 - Name Search Modify the Sorted Names program that...Ch. 9 - Charge Account Validation Recall that Programming...Ch. 9 - Prob. 7PECh. 9 - Sorting Benchmarks Modify the modules presented in...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Contrast the following terms: chief data officer; DBA data administration: database administration open source ...
Modern Database Management
Use the following tables for your answers to questions 3.7 through 3.51 : PET_OWNER (OwnerID, OwnerLasst Name, ...
Database Concepts (8th Edition)
What types of weld joints commonly employ fillet welds?
Degarmo's Materials And Processes In Manufacturing
If a process in a multiprogramming system could access memory cells outside its allotted area, how could it gai...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
For the circuit shown, find (a) the voltage υ, (b) the power delivered to the circuit by the current source, an...
Electric Circuits. (11th Edition)
Java programs normally go through five phases,,,and.
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
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
- Data Structure & Algorithm: Here is an array with exactly 15 elements:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15Suppose that we are doing a serial search for an element. Circle any elements that will be found by examining two or fewer numbers from the array.arrow_forwardSelect true or false for the statements below. Explain your answers if you like to receive partial credit Select true or false for the statements below. Explain your answers if you like to receive partial credit Which of the following is true about searching elements in an unordered array? With the data is unsorted, search is O(n) because if the element you are looking for is not there, you have to check every element in the array If you start at the end of the array and traverse to index 0, search improves to O(log n) because you only have to look at half of the array If you get lucky with checking the first element and find it immediately, then the worst case performance of search improves to O(n^2) Which of the following is true about searching elements in an ordered array? You cannot use binary search on an ordered array so the performance is O(n) If there are no holes in the array and the elements are all next to each other, then the performance for search improves to…arrow_forwardIn the square two dimensional array, the condition to navigate to (reach) the upper triangle elements of the primary diagonal * :is Note: (i) represents row index, (j) represents column index, and SIZE represents the array length i>j O isj O i+jSize-1 Oarrow_forward
- Assume the array is sorted according to the roll number. Jonny, as a school teacher conducted the test in the class and students submitted responses along with time duration to complete the test. Now your task is to find the student number who taken the most time. In kotlinarrow_forwardNone You are given 4 items as {value, weight pairs 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 weights 25) is taken fractionally to fill upto the knapsack capacity. That fraction is represented in format. What is the lowest possible value of b? ratio. The weight 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 valueol the item no. 4) ? Give your answer to at least two decimal places.arrow_forwardQ1: Suppose an array contains the following elements: -31 . . -27 . -9 14 17 18 Determine the number of comparisons needed to find each element in the array using a binary search. (explain in detail how to get the answer ) For example, three comparisons are needed to find -9. . -31 -27 14 17 48 7 29 30 48arrow_forward
- Please choose the answer and give the reasoning for it. The sequential search algorithm: 1. Requires the array to be ordered 2. Must always be implemented as a method 3. Uses a loop to step through an array, starting with the first element 4. Will not execute if the element is not in the arrayarrow_forwardBest Partition You are given an array of positive numbers of size N and an integer K. You need to partition the array into K continuous segments. For each segment, the sum of its elements needs to be calculated. The segment with the minimum sum is called the bestSegment and the sum of the elements of the bestSegment is called the bestSum. For all possible combinations of partitions of the array when divided into K segments, their bestSum needs to be calculated and the one among them with maximum value needs to be returned. Input Specification: input1: an array of N positive numbers input2: an integer N denoting the length of the array input3: an integer K Output Specification: Return an integer denoting the maximum value of all possible bestSum. Example 1: input1: (1,2,3,4} input2: 4 input3: 2 Output: 4 Explanation: You can partition the given array into 2 continuous segments in the following manner- • 123 14- the sum of individual segments is (6,4) and the bestSum is 4 • 12134- the…arrow_forwardQ2: How would you sort the array given below using quick sort algorithm? Trace the algorithm and show the array after each step. In every step, choose the first element as the pivotal. 1 3 4. 5n 7 20 50 10 90 40 30 80 70 60 O O Darrow_forward
- WAP to create array for storing marks of 20 students and find2. Highest marks3. Lowest marks4. Average marks.5. Count how many students failed( marks<30)arrow_forwardShow steps of insertion sort for the given array. You may need to add more rows to the table.arrow_forwardAssume that the maximum number of employees working in a company is 100 and all employees have personnel numbers (ID) between [1-999999]. Employees' numbers (IDs) will be stored in an array of size 100 . Assume that the ID of a personnel is 15426, then 15426 % 100 = 26 will be calculated and this ID will be assigned to the 26th index of the array. If an ID has already been assigned here, 15426 will be assigned to the 27th index of the array. If 27th index is also full, then an empty space must be searched by increasing the index number and the ID must be assigned when an empty space is found. (If the 99th index is reached when searching empty space, return to the index 0 and continue to search an empty space.) If all elements of the array are full, then the program must print an output indicating that "the array is full". The function that adds records should be given in the form below. This function returns the index number to which the ID is assigned. It must return -2 if the array…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
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License