Starting Out with Programming Logic and Design (4th Edition)
4th Edition
ISBN: 9780133985078
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 (4th Edition)
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
Consider the following program written in C syntax: void fun (int first, int second) { first += first; second +...
Concepts of Programming Languages (11th Edition)
Suppose there were two central processing units attached to the same memory and executing different programs. F...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
(Sales-Commission Calculator) One large chemical company pays its salespeople on a commission basis. The salesp...
C How to Program (8th Edition)
Use the Internet to research the history of the Python programming language, and answer the following questions...
Starting Out with Python (3rd Edition)
Write a program that will read a text file that contains an unknown number of movie review scores. Read the sco...
Java: An Introduction to Problem Solving and Programming (7th Edition)
Name three different C++ classes that can be used to create input streams.
Starting Out with C++: Early Objects
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_forwardThe first element in each array is accessed with index number 0. (e.g., array[0]). Select one: True Falsearrow_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_forward
- In 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_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_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_forwardWAP 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_forward
- Show 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_forwardUsing r create a 4×3×4 array where for each of the 3 students, a 4×3 matrix holds their six scores and six averages (i.e., two averages by scores, three averages by subject, and the grand average). The last (i.e., 21st) matrix should hold the elementwise averages of the previous 20 matrices. Do not use a loop. Ini A1 A2 B1 B2 C1 C2 RE 81.9 75.1 78.3 69.2 79.6 74.4 ON 82.7 72.6 85.3 78.9 78.3 75.7 KS 83.8 63.4 73.4 73.5 80.4 66.2 Ini is the student's initials, A1 is subject 1 first, A2 is subject 1 second, etc.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