inplace merging can be done.. but i dnt knw the exact algo.. but there is smthin called inplace merging
On Sat, Jul 3, 2010 at 10:34 PM, padmanaban sahadevan <[email protected] > wrote: > ya ppl....the underlying operation is to do merge 2 sorted arrays as we do > in merge sort.....but remember in merge sort the space complexity is not > O(1).....but here v need O(1)... > > > On Sat, Jul 3, 2010 at 9:57 PM, Anand <[email protected]> wrote: > >> @souravsain: >> Given an array of n elements and an integer k where k<n. Elemnts >> > > {a[0].....a[k] and a[k+1].....a[n] are already sorted. >> >> As per the question a{0} to a{k} is sorted and a{K+1} to a{n} is sorted >> so we look at the sequence in a{0} to a{k} and {n} to a{k+1} it makes a >> bitonic sequence. >> and if we apply bitonic merge on it, it gives a final sorted sequence. >> >> >> >> >> On Sat, Jul 3, 2010 at 12:23 AM, souravsain <[email protected]> wrote: >> >>> @Anand >>> >>> Please explain how you concluded that the array will first >>> continuously increase and then continuously decrease? Why can it not >>> be 2 continuous increase like [1,2,3,4,5,3,4,8] where [1,2,3,4,5] and >>> [3,4,8] are a[1] to a[k] and a[k+1] to a[N] respectively? Whill your >>> method work still? >>> >>> @Ankur, Correct me if my interpretation of the question is wrong. >>> >>> Sourav >>> >>> On Jul 3, 1:32 am, Anand <[email protected]> wrote: >>> > This is an example of bitonic sequence if we reverse the bottom half of >>> the >>> > array. >>> > Sequence is called Bitonics if the sequence of number first >>> > increases(ascending order) and then decrease(descending order). >>> > >>> > 1. We need to reverse the bottom half the array to make it bitonic. >>> > 2. Appy Bitonic Merge to get the final sorted array.: Complexity.O(n) >>> > >>> > In the below code, I have implemented sorting n/w to sort any kind of >>> array >>> > but for bitonic sequence we only bitonic merge function call which take >>> > O(n). >>> > Refer section Sorting network from Corman for more details >>> > >>> > http://codepad.org/ZhYEBqMw >>> > >>> > On Fri, Jul 2, 2010 at 11:30 AM, ANKUR BHARDWAJ <[email protected] >>> >wrote: >>> > >>> > > Given an array of n elements and an integer k where k<n. Elemnts >>> > > {a[0].....a[k] and a[k+1].....a[n] are already sorted. Give an >>> > > algorithm to sort in O(n) time and O(1) space. >>> > >>> > > -- >>> > > 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]<algogeeks%[email protected]> >>> <algogeeks%[email protected]<algogeeks%[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]<algogeeks%[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]<algogeeks%[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]<algogeeks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- 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.
