- 1

Hi! Can you write this code?

It is necessary to create a function Binary_Find (F, array []), which takes a number as an argument, and the array in which to search for this value, returns the ordinal number (index) of the element in the array that matches F, or -1 if the element is not found. The return must be implemented via a return statement. The task can be performed either through a recursive call (when the function calls itself) or through an iterative call (loop). Note: The program must first sort the original array, and then return the ordinal number of the element in the sorted array. If there are several such numbers in the array, its first occurrence is displayed.

21st Dec 2021, 10:10 AM
tsl 123
2 Réponses
+ 1
Hello tsl 123, The last paragraph of your Description mentioned that the array needs to be sorted before searching. It's possible that you were looking for binary search, and you can find relevant resources in "Learn" section such as this one ... https://www.sololearn.com/learn/664/?ref=app For implementation examples, you can search the "Code" section, the forum isn't the place to ask for codes ...
21st Dec 2021, 10:16 AM
Ipang
0
What's about this? W/O recursion or loop. https://code.sololearn.com/c1jaySS2igvP/?ref=app
21st Dec 2021, 11:12 PM
Coding Cat
Coding Cat - avatar