Archives

How to find the area of gray portion in the image ?

To find the area of gray portion, we  use the below equation Area of gray portion = Area of the semicircle on the Left hand side – Area of semicircle with diameter 2.6 cm + Area of semicircle with diameter 1.8 cm => 0.5 * π[0.5*(2.6+1.8)]^2 – 0.5*π(1.3)^2 + 0.5*π(0.9)^2 => 6.22035345411 sq cms Hope that […]

Search an element in sorted rotated array

Even though the array is rotated, we can still use binary search here by finding the point of rotation using the function findPivotIndex() as shown below. Once we find the pivot (point of rotation), divide the array in 2 halves, each of which will still be in sorted order and apply binary search on each […]