Unless sorting the array is forbidden, sort it and then use the
obvious O(n^2) algorithm. This can be done with only O(1) extra space.

If O(n) extra space is available, either use it to copy and sort the
original array, or use it as a hash table, again achieving O(n^2) in
either case.

If sorting is forbidden and using extra space is forbidden, then I
doubt that any algorithm less than O(n^3) exists.

Dave

On Dec 20, 4:41 am, bittu <[email protected]> wrote:
> can we find Pythagorean triples in an unsorted array in write program
> so that have minimum time complexity.
>
> regards
> Shashank

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to