Find the First Occurrence of a Number in an Array
This lesson will help you find the first occurrence of a number in an array using recursion.
First Occurrence of a Number
Given an array, find the first occurrence of a given number in that array and return the index of that number.
The following illustration shows how to do it:
Implementing the Code
The following code explains how to find the first occurrence of a number in an array.
Experiment with the code by changing the values of array and x to see how it works!
Understanding the Code
A recursive code can be broken down into two parts. The ...