Re: [algogeeks] maximum difference in an array

2011-03-30 Thread Senthil S
Sorting takes O (N logN) .. You can find the minimum and the maximum in a single traversal i.e O(N) time and return the difference of the two .. To find minimum and maximum you can do the following : i) Assign min = max = first element in the array. ii)Then traverse the array .. for each element in

Re: [algogeeks] maximum difference in an array

2011-03-30 Thread Subhransu
Don't you think sorting the array and take the first & last element ! ! ! *Subhransu Panigrahi * *Mobile:* *+91-9840931538* *Email:* subhransu.panigr...@gmail.com On Wed, Mar 30, 2011 at 12:43 PM, UTKARSH SRIVASTAV wrote: > Problem > Can anyone give me the efficient algo to know the the maxi

[algogeeks] maximum difference in an array

2011-03-30 Thread UTKARSH SRIVASTAV
Problem Can anyone give me the efficient algo to know the the maximum difference of two numbers in an arrayplease only tell the algo not code - *UTKARSH SRIVATAV* *CSE-3 B-Tech 2nd Year @MNNIT ALLAHABAD* -- You received this message because you are subscribed to the Google Groups "Al