The school wants to deploy an efficient method to store and search students' names. Student A...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The school wants to deploy an efficient method to store and search students' names. Student A suggests entering the names into an array and using binary search. (a) Explain why the array must be sorted before performing binary search. (b) State two features of a successful recursive function. Names are stored in Array in ascending order. Student A writes the recursive function below to search for Target in Array. It returns True if Target is found and False otherwise. FUNCTION B (Array, Target, Low, High) RETURNS BOOLEAN IF Low > High THEN RETURN False (Low High) div 2 IF Target < Array [Mid] THEN - B (Array, Target, Low, Mid 1) 01 02 03 04 ELSE 05 Mid 06 07 08 09 10 11 12 13 RETURN True ENDIF ENDIF 14 ELSE IF Target > Array [Mid] ELSE B (Array, Target, Mid + 1, High) ENDFUNCTION Note: the div operation returns an integer value after division, e.g. 7 div 2 = 3. (c) State the significance of line 02. (d) Name the type of error for lines 07 and 09. Modify these two lines to make the functio work. (e) Write down the statement to call the function to perform the binary search. Student B suggests storing the names in a hash table and using hash table search. (f) State two features of a good hashing algorithm. (g) Explain how two different records hashing to the same location can be managed. (h) Use time complexity to explain the advantage of a hash table search might have over binary search. The school wants to deploy an efficient method to store and search students' names. Student A suggests entering the names into an array and using binary search. (a) Explain why the array must be sorted before performing binary search. (b) State two features of a successful recursive function. Names are stored in Array in ascending order. Student A writes the recursive function below to search for Target in Array. It returns True if Target is found and False otherwise. FUNCTION B (Array, Target, Low, High) RETURNS BOOLEAN IF Low > High THEN RETURN False (Low High) div 2 IF Target < Array [Mid] THEN - B (Array, Target, Low, Mid 1) 01 02 03 04 ELSE 05 Mid 06 07 08 09 10 11 12 13 RETURN True ENDIF ENDIF 14 ELSE IF Target > Array [Mid] ELSE B (Array, Target, Mid + 1, High) ENDFUNCTION Note: the div operation returns an integer value after division, e.g. 7 div 2 = 3. (c) State the significance of line 02. (d) Name the type of error for lines 07 and 09. Modify these two lines to make the functio work. (e) Write down the statement to call the function to perform the binary search. Student B suggests storing the names in a hash table and using hash table search. (f) State two features of a good hashing algorithm. (g) Explain how two different records hashing to the same location can be managed. (h) Use time complexity to explain the advantage of a hash table search might have over binary search.
Expert Answer:
Related Book For
Chemistry The Central Science
ISBN: 978-0321696724
12th edition
Authors: Theodore Brown, Eugene LeMay, Bruce Bursten, Catherine Murphy, Patrick Woodward
Posted Date:
Students also viewed these computer network questions
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
1. The following table contains several definitions of terms that are used in Computer Science. Letter Definition A Cleaning up data entered by removing non-standard characters B Hiding or removing...
-
If Y (p) is the laplace transform of y(t), which is the solution of the initial value problem { + y(t) = - dt p+1 1+p sin t satisfying y (0) = 1 and y'(0)=0, then the Y(p) equals P -2p + 1+p (1+p) ...
-
The Thai baht (Bt) was devalued by the Thai government from BT25/$ to BT29/$ on July 2, 1997. What was the percentage devaluation of the baht?
-
If the monthly demand function is p = 7230 - 5q2 and the supply function before taxation is p3030q2, what tax per item will maximize the total revenue? p is the price per unit in dollars and q is the...
-
Derive the stiffness matrix of the bar element in longitudinal vibration whose cross-sectional area varies as \(A(x)=A_{0} e^{-(x / l)}\), where \(A_{0}\) is the area at the root (see Fig. 12.14)....
-
Thursday Afternoon sells housewares through three distribution channels-retail stores, Internet, and catalog sales. Each distribution channel is evaluated as an investment center. Selected results...
-
Your team decided to use strings for storing phone numbers. Now there is a debate on how to properly store the info in a collection. Your teammates are equally divided between lists, sets, and...
-
Graphically verify Eq. (13) for a lead absorber and Mo K, Rh K, and Ag K radiation. (The mass absorption coefficients of lead for these radiations are 122.8, 84.13, and 66.14 cm2 /g, respectively.)...
-
In Problems 27-30 suppose that, for a certain exam, a teacher grades on a curve. It is known that the mean is 50 and the standard deviation is 5. There are 45 students in the class. What is the...
-
The text suggests that the sliding window protocol can be used to implement flow control. We can imagine doing this by having the receiver delay ACKs, that is, not send the ACK until there is free...
-
Modify the simplex-talk socket program so that it uses UDP as the transport protocol rather than TCP. You will have to change SOCK_STREAM to SOCK_DGRAM in both client and server. Then, in the server,...
-
Suppose the round-trip propagation delay for Ethernet is 46.4 s. This yields a minimum packet size of 512 bits (464 bits corresponding to propagation delay + 48 bits of jam signal). (a) What happens...
-
Consider a client and server using an RPC mechanism that includes a channel abstraction and boot IDs. (a) Give a scenario involving server reboot in which an RPC request is sent twice by the client...
-
The wire in the video is 2.0 m long. It's a 21-gauge wire, meaning that its diameter is 0.723 mm (see, for instance, https://en wikipedia org/wiki/American_wire_gauge). What is the resistivity of...
-
Chao, Louis, and Mari, unrelated individuals, own all of the shares of Cerise Corporation. All three shareholders have been active in the management of Cerise since its inception. In the current...
-
An element crystallizes in a body-centered cubic lattice. The edge of the unit cell is 2.86 , and the density of the crystal is 7.92 g/cm3. Calculate the atomic weight of the element?
-
The temperature of a 5.00-L container of N2 gas is increased from 20oC to 250oC. If the volume is held constant, predict qualitatively how this change affects the following: (a) The average kinetic...
-
Which of the following are ionic, and which are molecular? (a) PF5 (b) NaI (c) SCl2 (d) Ca(NO3)2 (e) FeCl3 (f) LaP (g) CoCO3 (h) N2O4.
-
A data set has a median of 17, and six of the numbers in the data set are less than 17. The data set contains a total of n numbers. a. If n is odd, and exactly one number in the data set is equal to...
-
The Smith family in Example 3.5 had the good fortune to win a million-dollar prize in a lottery. Their annual income for each of the five years leading up to their lottery win are as follows: a....
-
In Jacobs statistics class, the final grade is a weighted mean of a homework grade, three midterm exam grades, and a final exam grade. The homework counts for 10% of the final grade, each midterm...
Study smarter with the SolutionInn App