Duration: 17 minutes
Summary: In this video we will talk about functions that call themselves. We refer to this as recursive functions. These functions need to have carefully planned exit conditions. Otherwise, we will end up with an infinite loop and eventually the stack will be full, and the program will crash. As an example, I will create an array that contains strings. We will first sort the array. Then have a binary search function that searched for an element in the array. This binary search function will look for the element in the middle of the array. If it is found, then we are done. If not, it compares the value to the one in the middle of the array. If the value is bigger, we do the same search again, but for the right portion of the array. Otherwise, we do the same search but for the left portion of the array. Imagine you are searching an array of 1,000,000 elements. You start with that number, then reduce to 500,000, then 250,000 and so on. This is why this search for very efficient. Keep in mind though that the array needs to be sorted first.
Methodology of the development of example: Good coding standard and simplified design.