Algorithm for calculating max and min value from an
array:
Algorithm
maxmin(int low, int high, int max, int min)
//low, high are used as index
//max, min are used as max & min value
{
if(low == high) then
min: = arr[low];
max: = arr[high];
else if((high -1 ) == low) then
if(arr[low] < arr[high]) then
max: = arr[high];
min: = arr[low];
else
min: = arr[high];
max: = arr[low];
else
mid: = (low + high)/2;
maxmin(low, mid, max, min);
maxmin(mid+1, high, max1, min1);
if(max < max1) then
max: = max1;
if (min>min1) then
min: = min1;
}
Total time required for finding max and min value
using divide and Conquer method:
So,
in the
asymptotic notation the time complexity of this algorithm is represented by O(n).
Thank you so much for this nice information. Hope so many people will get aware of this and useful as well. And please keep update like this.
ReplyDeleteText Analytics Tool
Data Analytics Solutions
Thank you so very much!!!
DeleteThank you so very much!!!
ReplyDeleteThank you very much!!!
ReplyDeleteThis information is impressive; I am inspired how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic
ReplyDeleteMazeevents
best event management company in chennai
event management companies in chennai