(a) Suppose we are performing a binary search on a sorted list called numbers initialized as...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(a) Suppose we are performing a binary search on a sorted list called numbers initialized as follows: # index 0 1 2 3 numbers [-2, 0, 1, 7, 4 5 6 7 8 9 10 11 12 13 9, 16, 19, 28, 31, 40, 52, 68, 85, 99] #search for the value 5 index= binary_search (numbers, 5) Write the indexes of the elements that would be examined by the binary search (the mid values in our algorithm's code) and write the value that would be returned from the search. Assume that we are using the binary search algorithm shown in lecture and section. Indexes examined: Value Returned: (b) Write the state of the elements of the list below after each of the first 3 passes of the outermost loop of the selection sort algorithm. numbers = [63, 9, 45, 72, 27, 18, 54, 36] selection_sort (numbers) (c) Trace the complete execution of the merge sort algorithm when called on the list below, similarly to the example trace of merge sort shown in the lecture slides. Show the sub-lists that are created by the algorithm and show the merging of sub-lists into larger sorted lists. numbers [63, 9, 45, 72, 27, 18, 54, 36] merge_sort (numbers) (a) Suppose we are performing a binary search on a sorted list called numbers initialized as follows: # index 0 1 2 3 numbers [-2, 0, 1, 7, 4 5 6 7 8 9 10 11 12 13 9, 16, 19, 28, 31, 40, 52, 68, 85, 99] #search for the value 5 index= binary_search (numbers, 5) Write the indexes of the elements that would be examined by the binary search (the mid values in our algorithm's code) and write the value that would be returned from the search. Assume that we are using the binary search algorithm shown in lecture and section. Indexes examined: Value Returned: (b) Write the state of the elements of the list below after each of the first 3 passes of the outermost loop of the selection sort algorithm. numbers = [63, 9, 45, 72, 27, 18, 54, 36] selection_sort (numbers) (c) Trace the complete execution of the merge sort algorithm when called on the list below, similarly to the example trace of merge sort shown in the lecture slides. Show the sub-lists that are created by the algorithm and show the merging of sub-lists into larger sorted lists. numbers [63, 9, 45, 72, 27, 18, 54, 36] merge_sort (numbers)
Expert Answer:
Related Book For
University Physics with Modern Physics
ISBN: 978-0321696861
13th edition
Authors: Hugh D. Young, Roger A. Freedman, A. Lewis Ford
Posted Date:
Students also viewed these programming questions
-
1 2 3 A 5 6 67 7 00 Question 1 You applied for a 28-year HIBOR mortgage loan for buying a property valued at $5,800,000. The interest rate is H + 1.35, capped at P-2.8%, where the current HIBOR is...
-
1. Consider the various data elements that would be gathered for prospective health insurance customers. Think about other situations which could be developed to target customers and the associated...
-
1234 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 A B Portions of the financial statements for PTO Products are provided below: Sales Cost of goods sold Gross margin Salaries expense PTO PRODUCTS...
-
Convert decimal + 49 and + 29 to binary, using the signed-2's-complement representation and enough digits to accommodate the numbers. Then perform the binary equivalent of ( +29) + (-49), (-29) +...
-
The cooling system of a truck engine contains 20.0 L of water. (1 L of water has a mass of 1 kg.) (a) If the engine is run until 845 kJ of heat is added, what is the change in temperature of the...
-
In hydrochloric acid, HOI reacts to give [ICl 2 ] . Use the potential diagrams below to explain why HOI disproportionates in aqueous acidic solution, but does not when the acid is aqueous HCl. [03]...
-
Turnover for the short time the company has been trading was \($2,520\) in July and around \($11,000\) in August. At the time of registering the business with the tax authority it was a service...
-
Woodpoint Furniture Manufacturing produces various lines of pine furniture. The plant is organized so that all similar functions are performed in one area, as shown in Exhibit 7-17. Most pieces of...
-
The _________ provides a portion of the system call interface for UNIX and Linux.
-
Eleven-Eleven, Inc. creates guided meditation programs for individuals. On November 30, 20Y9, the balances of selected accounts of Eleven-Eleven, Inc. are as follows: Prepare a classified balance...
-
Sphere P, having a radius of R, slides along a curved surface. At the position shown, the center of the sphere has a speed of u and an acceleration of a, as shown in the figure. At the position...
-
If not for Hong Kong, Sonya Madden believes she could never have made the quantum leap from investment banker to international fashion designer. Basing her business close to the supplies enabled the...
-
The Woberg Company, located near Aarhus, Denmark, manufactured dishwashers and garbage pulverizers for home use, and cooking equipment and commercial pulverizers for restaurants. A relatively young...
-
A professor and her husband, while on vacation in eastern Europe, found some beautifully handcrafted, fired-clay figurines for sale in Budapest. Displayed by the artist in a stall in a small open...
-
Mrs Kubo is the mother of an autistic child who fortunately was diagnosed when still very young. In order to help him develop word skills when he was still a small baby, Mrs Kubo started cutting out...
-
The Sarbanes-Oxley Act determines: (a) international tax regulations. (b) internal control standards as enforced by the IASB. (c) internal control standards of U.S. publicly traded companies. (d)...
-
Determine the unknown angle value (x) in the diagram below. Provide a reason to justify each calculation. A 87 B E 130 130 50 C I
-
Consider the following cash flows in Table P5.5. (a) Calculate the payback period for each project. (b) Determine whether it is meaningful to calculate a payback period for project D. (c) Assuming...
-
Currents in dc transmission lines can be 100 A or more. Some people have expressed concern that the electromagnetic fields (EMFs) from such lines near their homes could cause health dangers. For a...
-
At t = 0 a very small object with mass 0.400 mg and charge +9.00 C is traveling at 125 m/s in the -x direction. The charge is moving in a uniform electric field that is in the +y -direction and that...
-
A narrow, U-shaped glass tube with open ends is filled with 25.0 cm of oil (of specific gravity 0.80) and 25.0 cm of water on opposite sides, with a barrier separating the liquids (Fig. P12.58)....
-
The solar system is like an atom in that both (a) are governed principally through the electric force. (b) consist of a central body surrounded by objects moving in elliptical paths. (c) are composed...
-
The nebular theory is based on the observation that the solar system (a) follows patterns indicating that it formed progressively from physical processes. (b) has a structure much like an atom. (c)...
-
When a contracting hot ball of gas spins into a disk shape, it cools faster due to (a) increased radiation transfer. (b) increased surface area. (c) decreased insulation. (d) increased convection...
Study smarter with the SolutionInn App