Re: [algogeeks] do this: two numbers with min diff

2010-09-23 Thread Nishant Agarwal
int minDiff(int arr[], int arr_size) { int min_diff = arr[1] - arr[0]; int max_element = arr[0]; int i; for(i = 1; i arr_size; i++) { if(arr[i] - max_element min_diff) min_diff = arr[i] - max_element; if(arr[i] max_element) max_element = arr[i]; } return

[algogeeks] do this: two numbers with min diff

2010-09-19 Thread Srinivas
2 nos with min diff given an array of size n. find 2 numbers from array whose difference is least in O(n) w/o using xtra space( i mean constant space) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to