tianqio
December 13th, 2006, 08:44 PM
given an positive array, find the biggest element c where c = a*b and a,b are elements of this array too. How fast you can?
|
Click to See Complete Forum and Search --> : a google internship exam algorithm tianqio December 13th, 2006, 08:44 PM given an positive array, find the biggest element c where c = a*b and a,b are elements of this array too. How fast you can? Yves M December 14th, 2006, 02:20 PM It depends on the range of the numbers (i.e. are they integers, doubles, some unbounded long numbers, etc.?) For ints, it's possible to do it in O(NlogN) in practise (although for N<10 it's technically possible to have a N^2 runtime, it doesn't enter into the O notation). tianqio December 14th, 2006, 08:35 PM the numbers are int. can you give a detail discription of your nlgn algorithm? thanks. xusword December 21st, 2006, 09:40 AM I do not know how others get O(n log n). I really do not think defining a range would help, big O notation wise... The algorithms I came up with are all O(n square log n) in worst case. Some are clearly better then the other. (Due to the fact a, b, c are all intgers, we can define many trick to narrow the range of each variable) Would the person who came up with n log n complexity care to share the algorithm with us? codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |