Re: [algogeeks] Sorting in O(n)

2012-05-23 Thread Saurabh Yadav
+1 mithun kumar !!

using bit array or bitmap index gives the best solution ( O(n) )
the only limitation is we should know the maximum limit of the number,
which is provided in this problem :D


Thanks  Regards
Saurabh Yadav

-- 
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] Sorting in O(n)

2012-05-21 Thread Mithun Kumar
using bit array we can sort elements in O(1)

-mithun



On Sat, May 5, 2012 at 12:17 AM, Algobiz deepak.arulkan...@gmail.comwrote:

 How to sort n numbers in the range of 1 to n^2 in O(n).. Any ideas?

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/PGgMdaIbGIsJ.
 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] Sorting in O(n)

2012-05-05 Thread saurabh singh
After giving some thought,I think even radix sort may not be sufficient.
Complexity of radix sort is O(k*n) where k is the number of buckets
required to sort the given range.
The number of buckets is proportional to the number of bits required to
represent the *maximum number in the given range.*For our case the maximum
number is O(n^2).Hence *the number of buckets required would be
proportional to log(n^2) in the worst case.*
Hence the worst case complexity for the given constraints using radix sort
would be *O(n*(log n^2)) = O(n*logn).*
This is no better than comparision sort.A slight optimization that we can
make is to use a higher base which would reduce the number of buckets
required but would add the cost of converting each number into  the higher
base.
Somehow I am getting convinced worst case O(n) algorithm may not be
possible.Working on the mathematical proof.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, May 5, 2012 at 8:37 AM, saurabh singh saurab...@gmail.com wrote:

 @cegprakash They are n numbers lying in the range 1 to n^2.Not necessarily
 sorted.
 eg 3 4 1 2 5 8 (6 numbers satisfying the conditions given in the problem)
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Sat, May 5, 2012 at 5:17 AM, Prakash D cegprak...@gmail.com wrote:

 The range 1 to n^2 is already sorted

 On Sat, May 5, 2012 at 12:17 AM, Algobiz deepak.arulkan...@gmail.com
 wrote:
  How to sort n numbers in the range of 1 to n^2 in O(n).. Any ideas?
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To view this discussion on the web visit
  https://groups.google.com/d/msg/algogeeks/-/PGgMdaIbGIsJ.
  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] Sorting in O(n)

2012-05-05 Thread Jeevitesh
Hi all,

I am new to this group.

My last post was deleted i do not know the reason behind it.

I will explain my logic here:-

as the range is 1 to n^2 we have a input array like input[n^2].
We can take a auxillary array of size n^2 like aux[n^2].
Scan the input array.
For each input input[i] increment by one corresponding aux[input[i]].
After this just iterate through the aux array printing the index aux[i]
times.

This way we can sort it in O(n) time.

On Sat, May 5, 2012 at 2:02 PM, saurabh singh saurab...@gmail.com wrote:

 After giving some thought,I think even radix sort may not be sufficient.
 Complexity of radix sort is O(k*n) where k is the number of buckets
 required to sort the given range.
 The number of buckets is proportional to the number of bits required to
 represent the *maximum number in the given range.*For our case the
 maximum number is O(n^2).Hence *the number of buckets required would be
 proportional to log(n^2) in the worst case.*
 Hence the worst case complexity for the given constraints using radix sort
 would be *O(n*(log n^2)) = O(n*logn).*
 This is no better than comparision sort.A slight optimization that we can
 make is to use a higher base which would reduce the number of buckets
 required but would add the cost of converting each number into  the higher
 base.
 Somehow I am getting convinced worst case O(n) algorithm may not be
 possible.Working on the mathematical proof.

 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Sat, May 5, 2012 at 8:37 AM, saurabh singh saurab...@gmail.com wrote:

 @cegprakash They are n numbers lying in the range 1 to n^2.Not
 necessarily sorted.
 eg 3 4 1 2 5 8 (6 numbers satisfying the conditions given in the problem)
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Sat, May 5, 2012 at 5:17 AM, Prakash D cegprak...@gmail.com wrote:

 The range 1 to n^2 is already sorted

 On Sat, May 5, 2012 at 12:17 AM, Algobiz deepak.arulkan...@gmail.com
 wrote:
  How to sort n numbers in the range of 1 to n^2 in O(n).. Any ideas?
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To view this discussion on the web visit
  https://groups.google.com/d/msg/algogeeks/-/PGgMdaIbGIsJ.
  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.




-- 
*Thanks,
Jeevitesh Shekhar Singh.*

-- 
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] Sorting in O(n)

2012-05-05 Thread saurabh singh
Consider the case
n=6
array elements :-
{36 36 36 36 36 36}
How many iterations your code makes?
Consider another case
n=100
array={1e12,1e12 ..repeated 10^6 times}
How many iterations your code make?
Are the iterations still proportional to n that is the number of elements
in the array?
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, May 5, 2012 at 2:14 PM, Jeevitesh jeeviteshshekha...@gmail.comwrote:

 Hi all,

 I am new to this group.

 My last post was deleted i do not know the reason behind it.

 I will explain my logic here:-

 as the range is 1 to n^2 we have a input array like input[n^2].
 We can take a auxillary array of size n^2 like aux[n^2].
 Scan the input array.
 For each input input[i] increment by one corresponding aux[input[i]].
 After this just iterate through the aux array printing the index aux[i]
 times.

 This way we can sort it in O(n) time.


 On Sat, May 5, 2012 at 2:02 PM, saurabh singh saurab...@gmail.com wrote:

 After giving some thought,I think even radix sort may not be sufficient.
 Complexity of radix sort is O(k*n) where k is the number of buckets
 required to sort the given range.
 The number of buckets is proportional to the number of bits required to
 represent the *maximum number in the given range.*For our case the
 maximum number is O(n^2).Hence *the number of buckets required would be
 proportional to log(n^2) in the worst case.*
 Hence the worst case complexity for the given constraints using radix
 sort would be *O(n*(log n^2)) = O(n*logn).*
 This is no better than comparision sort.A slight optimization that we can
 make is to use a higher base which would reduce the number of buckets
 required but would add the cost of converting each number into  the higher
 base.
 Somehow I am getting convinced worst case O(n) algorithm may not be
 possible.Working on the mathematical proof.

 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Sat, May 5, 2012 at 8:37 AM, saurabh singh saurab...@gmail.comwrote:

 @cegprakash They are n numbers lying in the range 1 to n^2.Not
 necessarily sorted.
 eg 3 4 1 2 5 8 (6 numbers satisfying the conditions given in the problem)
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Sat, May 5, 2012 at 5:17 AM, Prakash D cegprak...@gmail.com wrote:

 The range 1 to n^2 is already sorted

 On Sat, May 5, 2012 at 12:17 AM, Algobiz deepak.arulkan...@gmail.com
 wrote:
  How to sort n numbers in the range of 1 to n^2 in O(n).. Any ideas?
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To view this discussion on the web visit
  https://groups.google.com/d/msg/algogeeks/-/PGgMdaIbGIsJ.
  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.




 --
 *Thanks,
 Jeevitesh Shekhar Singh.*


  --
 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] Sorting in O(n)

2012-05-04 Thread Prakash D
The range 1 to n^2 is already sorted

On Sat, May 5, 2012 at 12:17 AM, Algobiz deepak.arulkan...@gmail.com wrote:
 How to sort n numbers in the range of 1 to n^2 in O(n).. Any ideas?

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/PGgMdaIbGIsJ.
 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] Sorting in O(n)

2012-05-04 Thread saurabh singh
@cegprakash They are n numbers lying in the range 1 to n^2.Not necessarily
sorted.
eg 3 4 1 2 5 8 (6 numbers satisfying the conditions given in the problem)
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sat, May 5, 2012 at 5:17 AM, Prakash D cegprak...@gmail.com wrote:

 The range 1 to n^2 is already sorted

 On Sat, May 5, 2012 at 12:17 AM, Algobiz deepak.arulkan...@gmail.com
 wrote:
  How to sort n numbers in the range of 1 to n^2 in O(n).. Any ideas?
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To view this discussion on the web visit
  https://groups.google.com/d/msg/algogeeks/-/PGgMdaIbGIsJ.
  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] sorting in O(n) time

2011-08-02 Thread Surendra Gupta
Counting sort, radix sort,  .

On Wed, Aug 3, 2011 at 10:58 AM, AMAN AGARWAL mnnit.a...@gmail.com wrote:

 Hi,

 How can we sort one unsorted int array with O(n).

 Unsorted : {4,2,6,1,5,5,1,2,45,444,44,45,4,1}
 Sorted : {1,1,1,2,2,4,4,5,5,6,44,45,45,444}

 Is there any sorting method which gives us O(n) time complexity???

 Please tell the algo if anybody knows it.

 --
 AMAN AGARWAL
 Success is not final, Failure is not fatal: It is the courage to continue
 that counts!

 --
 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] sorting in O(n) time

2011-08-02 Thread Nitin Nizhawan
counting sort

 http://en.wikipedia.org/wiki/Counting_sort

Thanks
NItin

On Wed, Aug 3, 2011 at 10:58 AM, AMAN AGARWAL mnnit.a...@gmail.com wrote:

 Hi,

 How can we sort one unsorted int array with O(n).

 Unsorted : {4,2,6,1,5,5,1,2,45,444,44,45,4,1}
 Sorted : {1,1,1,2,2,4,4,5,5,6,44,45,45,444}

 Is there any sorting method which gives us O(n) time complexity???

 Please tell the algo if anybody knows it.

 --
 AMAN AGARWAL
 Success is not final, Failure is not fatal: It is the courage to continue
 that counts!

 --
 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] Sorting in O(n)

2011-07-23 Thread rajeev bharshetty
Given a valid range sort keys, the linked list can be sorted in O9n) time
using counting sort which takes O(n+k) comparisons to sort the list of K
elements .

On Sat, Jul 23, 2011 at 9:58 AM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 10^9--10^9 - 8- 7-  NULL . It wont help in this case...


 On Sat, Jul 23, 2011 at 9:55 AM, keyan karthi 
 keyankarthi1...@gmail.comwrote:

 counting sort ll help to some extent... find the min and max element O(n)
 now u just need an array of size  max-min to store the values then
 just traverse the list and while updating u do value+min... still it is not
 suitable if the magnitude is high.


 On Sat, Jul 23, 2011 at 9:45 AM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 n logn merge sort.count sort only when range is
 known.


 On Sat, Jul 23, 2011 at 1:35 AM, sunny agrawal 
 sunny816.i...@gmail.comwrote:

 Cannot be done in O(N) if elements of list can take any value because
 then counting sort wont help

 On Sat, Jul 23, 2011 at 1:24 AM, Pankaj jatka.oppimi...@gmail.comwrote:

 For linklist? How


 On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal 
 kamakshi...@gmail.com wrote:

 use counting sort..


 On Sat, Jul 23, 2011 at 1:22 AM, rShetty rajeevr...@gmail.comwrote:

 How to sort Linked lists in O(n) time ??
 Give the algorithm or the explanation or clue to tackle the problem

 --
 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,
 Kamakshi
 kamakshi...@gmail.com

  --
 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.




 --
 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.




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.

  --
 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.




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.

  --
 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
Rajeev N B http://www.opensourcemania.co.cc

-- 
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] Sorting in O(n)

2011-07-22 Thread Kamakshii Aggarwal
use counting sort..

On Sat, Jul 23, 2011 at 1:22 AM, rShetty rajeevr...@gmail.com wrote:

 How to sort Linked lists in O(n) time ??
 Give the algorithm or the explanation or clue to tackle the problem

 --
 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,
Kamakshi
kamakshi...@gmail.com

-- 
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] Sorting in O(n)

2011-07-22 Thread Pankaj
For linklist? How

On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:

 use counting sort..


 On Sat, Jul 23, 2011 at 1:22 AM, rShetty rajeevr...@gmail.com wrote:

 How to sort Linked lists in O(n) time ??
 Give the algorithm or the explanation or clue to tackle the problem

 --
 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,
 Kamakshi
 kamakshi...@gmail.com

  --
 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] Sorting in O(n)

2011-07-22 Thread kashish jain
actually its a work around...first traverse the list and store it in an
array..
sort the array in o(n)
then replace the content of the linked list using the values in the array


On Sat, Jul 23, 2011 at 1:24 AM, Pankaj jatka.oppimi...@gmail.com wrote:

 For linklist? How


 On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal kamakshi...@gmail.com
  wrote:

 use counting sort..


 On Sat, Jul 23, 2011 at 1:22 AM, rShetty rajeevr...@gmail.com wrote:

 How to sort Linked lists in O(n) time ??
 Give the algorithm or the explanation or clue to tackle the problem

 --
 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,
 Kamakshi
 kamakshi...@gmail.com

  --
 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] Sorting in O(n)

2011-07-22 Thread sunny agrawal
Cannot be done in O(N) if elements of list can take any value because then
counting sort wont help

On Sat, Jul 23, 2011 at 1:24 AM, Pankaj jatka.oppimi...@gmail.com wrote:

 For linklist? How


 On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal kamakshi...@gmail.com
  wrote:

 use counting sort..


 On Sat, Jul 23, 2011 at 1:22 AM, rShetty rajeevr...@gmail.com wrote:

 How to sort Linked lists in O(n) time ??
 Give the algorithm or the explanation or clue to tackle the problem

 --
 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,
 Kamakshi
 kamakshi...@gmail.com

  --
 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.




-- 
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] Sorting in O(n)

2011-07-22 Thread Ankur Khurana
n logn merge sort.count sort only when range is known.

On Sat, Jul 23, 2011 at 1:35 AM, sunny agrawal sunny816.i...@gmail.comwrote:

 Cannot be done in O(N) if elements of list can take any value because then
 counting sort wont help

 On Sat, Jul 23, 2011 at 1:24 AM, Pankaj jatka.oppimi...@gmail.com wrote:

 For linklist? How


 On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal 
 kamakshi...@gmail.com wrote:

 use counting sort..


 On Sat, Jul 23, 2011 at 1:22 AM, rShetty rajeevr...@gmail.com wrote:

 How to sort Linked lists in O(n) time ??
 Give the algorithm or the explanation or clue to tackle the problem

 --
 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,
 Kamakshi
 kamakshi...@gmail.com

  --
 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.




 --
 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.




-- 
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
Delhi.

-- 
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] Sorting in O(n)

2011-07-22 Thread keyan karthi
counting sort ll help to some extent... find the min and max element O(n)
now u just need an array of size  max-min to store the values then
just traverse the list and while updating u do value+min... still it is not
suitable if the magnitude is high.

On Sat, Jul 23, 2011 at 9:45 AM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 n logn merge sort.count sort only when range is known.


 On Sat, Jul 23, 2011 at 1:35 AM, sunny agrawal sunny816.i...@gmail.comwrote:

 Cannot be done in O(N) if elements of list can take any value because then
 counting sort wont help

 On Sat, Jul 23, 2011 at 1:24 AM, Pankaj jatka.oppimi...@gmail.comwrote:

 For linklist? How


 On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal 
 kamakshi...@gmail.com wrote:

 use counting sort..


 On Sat, Jul 23, 2011 at 1:22 AM, rShetty rajeevr...@gmail.com wrote:

 How to sort Linked lists in O(n) time ??
 Give the algorithm or the explanation or clue to tackle the problem

 --
 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,
 Kamakshi
 kamakshi...@gmail.com

  --
 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.




 --
 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.




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.

  --
 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] Sorting in O(n)

2011-07-22 Thread Ankur Khurana
10^9--10^9 - 8- 7-  NULL . It wont help in this case...

On Sat, Jul 23, 2011 at 9:55 AM, keyan karthi keyankarthi1...@gmail.comwrote:

 counting sort ll help to some extent... find the min and max element O(n)
 now u just need an array of size  max-min to store the values then
 just traverse the list and while updating u do value+min... still it is not
 suitable if the magnitude is high.


 On Sat, Jul 23, 2011 at 9:45 AM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 n logn merge sort.count sort only when range is known.


 On Sat, Jul 23, 2011 at 1:35 AM, sunny agrawal 
 sunny816.i...@gmail.comwrote:

 Cannot be done in O(N) if elements of list can take any value because
 then counting sort wont help

 On Sat, Jul 23, 2011 at 1:24 AM, Pankaj jatka.oppimi...@gmail.comwrote:

 For linklist? How


 On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal 
 kamakshi...@gmail.com wrote:

 use counting sort..


 On Sat, Jul 23, 2011 at 1:22 AM, rShetty rajeevr...@gmail.com wrote:

 How to sort Linked lists in O(n) time ??
 Give the algorithm or the explanation or clue to tackle the problem

 --
 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,
 Kamakshi
 kamakshi...@gmail.com

  --
 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.




 --
 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.




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.

  --
 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.




-- 
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
Delhi.

-- 
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.