Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The school wants to deploy an efficient method to store and search students' names. Student A suggests entering the names into an array and
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started