I am doing an excersise with recursion having correct return codes. If it matches or not matches an array element. I have managed to do it using a global variable but it doesn't seem that clean. Or is the right way to do it?
Any help would be greatly appreciated.
Here is the question :
Write a recursive function that takes a sorted array and a target element and finds that element in the array (returning the index, or -1 if the element isn’t in the array). How fast can you make this search? Can you do better than looking having to look at every element?