Algorithm for Finding the Maximum and Minimum using Divide and Conquer Technique
For Complete YouTube Video: Click Here
In this class, we will try to understand the Algorithm for Finding the Maximum and Minimum using Divide and Conquer Technique.
In previous classes, we have discussed the concepts of Divide and Conquer and the Working Mechanism for finding the Maximum and Minimum.
Algorithm for Finding the Maximum and Minimum using Divide and Conquer Technique
The recursive algorithm for finding the maximum and minimum is shown below.
We will consider the array of elements shown below for a better understanding.
The first line of the algorithm is the stopping condition for the division.
The division of the problem into sub-problems is done by finding the mid-value.
The formula used for finding the mid-value is
mid = Floor( ( Low + High ) / 2).
The stopping condition used is y – x <= 1.
The above condition will stop its division if the array after the sub-division has either two elements or only one element.
If the above stopping condition is false, the other part of the algorithm will get executed.
A detailed explanation of the algorithm is in the above YouTube Link.