I don’t understand what is floor and what is ceil
and the below problem
The number of comparisons required to find maximum and minimum in the given array of n- element using divide and conquer:
ciel(3n/2)
ciel(3n/2)+2
floor(3n/2)
floor(3n/2)-2
I don’t understand what is floor and what is ceil
and the below problem
The number of comparisons required to find maximum and minimum in the given array of n- element using divide and conquer:
ciel(3n/2)
ciel(3n/2)+2
floor(3n/2)
floor(3n/2)-2
hey @arjunsabu99
ciel(x) Returns the smallest integer that is greater than or equal to x (i.e : rounds up the nearest integer).
Input : 2.5
Output : 3
Input : -2.1
Output : -2
floor(x) : Returns the largest integer that is smaller than or equal to x (i.e : rounds downs the nearest integer).
Input : 2.5
Output : 2
Input : -2.1
Output : -3
1Pick 2 elements(a, b), compare them. (say a > b)
2. Update min by comparing (min, b)
3. Update max by comparing (max, a)
Therefore, we need 3 comparisons for each 2 elements, so total number of required comparisons will be (3n)/2 – 2, because we do not need to update min or max in the very first step.