Re: [algogeeks] Sort IT
How is it possible?? On Tue, Aug 2, 2011 at 7:41 PM, payel roy wrote: > It may create duplicate numbers while converting into base N. How > do recognize them while converting into base(N^2)?? > > > On 2 August 2011 17:20, Harshit Kapoor wrote: > >> I think that we can do it by first passing through an array once and >> convert all the interger to the base N in O(N). Since all elements are in >> the range 1 to N^2 they can have atmost 3 digits.Now apply radix sort which >> will be O( dn ) where d=3 in this case .=> O(n) when done convert them back >> to decimal notation in O(N) . >> But here N must be maximum no of single digit characters representable in >> ur system. >> >> Check if possible >> >> >> >> On Tue, Aug 2, 2011 at 1:02 PM, payel roy wrote: >> >>> Can you please elaborate ?? >>> >>> >>> On 2 August 2011 12:38, sunny agrawal wrote: >>> Radix sort is one of the solution. because this Question is in the section Radix sort in CLRS. :) On Tue, Aug 2, 2011 at 11:10 AM, Ravinder Kumar wrote: > I have little thought on this : > > divide the whole array by n and store their remainder also in an array > now number in original array are in range 1-n > sort the array and when two number with same break the tie using > remainder array > recreate the array using remainder array . > -- > *With Regards :* > > Ravinder Kumar > B.Tech Final Year > Computer Science and Engineering > MNNIT Allahabad > > > -- > You received this message because you are subscribed to the Google > Groups "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> 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 algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Sort IT
int a[N^2]={0},i,j; for(i=0;i>j; a[j]++; } for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Sort IT
we can use radix sort On Tue, Aug 2, 2011 at 7:41 PM, payel roy wrote: > It may create duplicate numbers while converting into base N. How > do recognize them while converting into base(N^2)?? > > > On 2 August 2011 17:20, Harshit Kapoor wrote: > >> I think that we can do it by first passing through an array once and >> convert all the interger to the base N in O(N). Since all elements are in >> the range 1 to N^2 they can have atmost 3 digits.Now apply radix sort which >> will be O( dn ) where d=3 in this case .=> O(n) when done convert them back >> to decimal notation in O(N) . >> But here N must be maximum no of single digit characters representable in >> ur system. >> >> Check if possible >> >> >> >> On Tue, Aug 2, 2011 at 1:02 PM, payel roy wrote: >> >>> Can you please elaborate ?? >>> >>> >>> On 2 August 2011 12:38, sunny agrawal wrote: >>> Radix sort is one of the solution. because this Question is in the section Radix sort in CLRS. :) On Tue, Aug 2, 2011 at 11:10 AM, Ravinder Kumar wrote: > I have little thought on this : > > divide the whole array by n and store their remainder also in an array > now number in original array are in range 1-n > sort the array and when two number with same break the tie using > remainder array > recreate the array using remainder array . > -- > *With Regards :* > > Ravinder Kumar > B.Tech Final Year > Computer Science and Engineering > MNNIT Allahabad > > > -- > You received this message because you are subscribed to the Google > Groups "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> 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 algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- best wishes!! Vaibhav MCA -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Sort IT
It may create duplicate numbers while converting into base N. How do recognize them while converting into base(N^2)?? On 2 August 2011 17:20, Harshit Kapoor wrote: > I think that we can do it by first passing through an array once and > convert all the interger to the base N in O(N). Since all elements are in > the range 1 to N^2 they can have atmost 3 digits.Now apply radix sort which > will be O( dn ) where d=3 in this case .=> O(n) when done convert them back > to decimal notation in O(N) . > But here N must be maximum no of single digit characters representable in > ur system. > > Check if possible > > > > On Tue, Aug 2, 2011 at 1:02 PM, payel roy wrote: > >> Can you please elaborate ?? >> >> >> On 2 August 2011 12:38, sunny agrawal wrote: >> >>> Radix sort is one of the solution. >>> because this Question is in the section Radix sort in CLRS. :) >>> >>> >>> On Tue, Aug 2, 2011 at 11:10 AM, Ravinder Kumar wrote: >>> I have little thought on this : divide the whole array by n and store their remainder also in an array now number in original array are in range 1-n sort the array and when two number with same break the tie using remainder array recreate the array using remainder array . -- *With Regards :* Ravinder Kumar B.Tech Final Year Computer Science and Engineering MNNIT Allahabad -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. >>> >>> >>> >>> -- >>> Sunny Aggrawal >>> B-Tech IV year,CSI >>> Indian Institute Of Technology,Roorkee >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> 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 algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Sort IT
I think that we can do it by first passing through an array once and convert all the interger to the base N in O(N). Since all elements are in the range 1 to N^2 they can have atmost 3 digits.Now apply radix sort which will be O( dn ) where d=3 in this case .=> O(n) when done convert them back to decimal notation in O(N) . But here N must be maximum no of single digit characters representable in ur system. Check if possible On Tue, Aug 2, 2011 at 1:02 PM, payel roy wrote: > Can you please elaborate ?? > > > On 2 August 2011 12:38, sunny agrawal wrote: > >> Radix sort is one of the solution. >> because this Question is in the section Radix sort in CLRS. :) >> >> >> On Tue, Aug 2, 2011 at 11:10 AM, Ravinder Kumar wrote: >> >>> I have little thought on this : >>> >>> divide the whole array by n and store their remainder also in an array >>> now number in original array are in range 1-n >>> sort the array and when two number with same break the tie using >>> remainder array >>> recreate the array using remainder array . >>> -- >>> *With Regards :* >>> >>> Ravinder Kumar >>> B.Tech Final Year >>> Computer Science and Engineering >>> MNNIT Allahabad >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> Sunny Aggrawal >> B-Tech IV year,CSI >> Indian Institute Of Technology,Roorkee >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Sort IT
Can you please elaborate ?? On 2 August 2011 12:38, sunny agrawal wrote: > Radix sort is one of the solution. > because this Question is in the section Radix sort in CLRS. :) > > > On Tue, Aug 2, 2011 at 11:10 AM, Ravinder Kumar wrote: > >> I have little thought on this : >> >> divide the whole array by n and store their remainder also in an array >> now number in original array are in range 1-n >> sort the array and when two number with same break the tie using remainder >> array >> recreate the array using remainder array . >> -- >> *With Regards :* >> >> Ravinder Kumar >> B.Tech Final Year >> Computer Science and Engineering >> MNNIT Allahabad >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Sunny Aggrawal > B-Tech IV year,CSI > Indian Institute Of Technology,Roorkee > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Sort IT
Radix sort is one of the solution. because this Question is in the section Radix sort in CLRS. :) On Tue, Aug 2, 2011 at 11:10 AM, Ravinder Kumar wrote: > I have little thought on this : > > divide the whole array by n and store their remainder also in an array > now number in original array are in range 1-n > sort the array and when two number with same break the tie using remainder > array > recreate the array using remainder array . > -- > *With Regards :* > > Ravinder Kumar > B.Tech Final Year > Computer Science and Engineering > MNNIT Allahabad > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Sort IT
I have little thought on this : divide the whole array by n and store their remainder also in an array now number in original array are in range 1-n sort the array and when two number with same break the tie using remainder array recreate the array using remainder array . -- *With Regards :* Ravinder Kumar B.Tech Final Year Computer Science and Engineering MNNIT Allahabad -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Sort IT
@ankit: Thats what i am saying as well .If The range is till N^2. how can we sort it in linear time?? If you know the answer please post it. On 1 August 2011 21:47, ankit sambyal wrote: > @raja : The range is 1-N^2 and not 1-N. Had it been 1-N , we could have > easily sorted the array in O(N) time using bit map. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Sort IT
@raja : The range is 1-N^2 and not 1-N. Had it been 1-N , we could have easily sorted the array in O(N) time using bit map. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Sort IT
How is it possible.If the range is 1 to N then we could use counting sort.But how can we do it in linear time .Any kind of sorting algorithm exists for this case?? On 1 August 2011 21:03, payel saha wrote: > > > You have an integer array of length N, containing values in the range > 1,2,3…N^2. Sort the array in O(N) time > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Sort IT
You have an integer array of length N, containing values in the range 1,2,3…N^2. Sort the array in O(N) time -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.