Find your content:

Search form

You are here

How to select middle element in the array?

 
Share

How to select middle element in the array?

There are two ways to find the middle element of the array.

int mid = start+end/2

it has a problem what happen if start or end has INT_MAX value or both. It throws integer overflow error. In order to avoid this use the below approach

int mid = start+ ( end - start)/2

 

My Block Status

My Block Content