Construct a simple binary tree out of the numbers mentioned and then max heapifying might help.
Besides, a simple descending order sort will give us the same result. Most of the sorting algorithms take O(nLog(n)) time on average. On Tue, Nov 6, 2012 at 9:11 AM, atul anand <[email protected]> wrote: > building tree will take O(n) time but for each node we need to find max > i.e > i = max (inorder, start, end); > > so complexity in worst case will we O(n^2). > > > On Tue, Nov 6, 2012 at 12:26 AM, shady <[email protected]> wrote: > >> Sorting takes linear time, but it doesnt get repeated n times, >> >> it is like - T(n) = 2*T(n/2) + O(n) >> >> worst case solution is O(n^2) >> >> it is similar to quick sort.... >> >> >> On Mon, Nov 5, 2012 at 9:15 PM, rahul sharma <[email protected]>wrote: >> >>> dude n for build tree and n in this for finding maximun??so >>> n*(n/2)=o(n^2) >>> >>> On Mon, Nov 5, 2012 at 8:54 PM, shady <[email protected]> wrote: >>> >>>> Here the time complexity of the solution should be O(n * log(n)).... >>>> http://www.geeksforgeeks.org/archives/21781 >>>> >>>> -- >>>> 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. >>>> >>> >>> -- >>> 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. >>> >> >> -- >> 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. >> > > -- > 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. > -- Umer -- 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.
