[algogeeks] Re: How to Sort a Stack in ascending order

2006-05-05 Thread Sriram narasimhan
i dont think it is specific for array implimentation of stacks.   Sriram.  On 5/6/06, akshay ranjan <[EMAIL PROTECTED]> wrote: isn't this specific for array implementation of stack onlyits written in the original ques that no assumptions about the implementation are to be made On 5/5/06, harsh

[algogeeks] DNA sequence

2006-05-05 Thread metalik
I am interested in one of the problems that I encountered in one of the server for programming contest but I could not solve it for a long time. Given small number (<=10) of DNA disease segments (of characters A,G,T,C) of small length <=10, ask how many DNA sequences of a given length (<=2000

[algogeeks] Re: How to Sort a Stack in ascending order

2006-05-05 Thread akshay ranjan
isn't this specific for array implementation of stack onlyits written in the original ques that no assumptions about the implementation are to be madeOn 5/5/06, harsh <[EMAIL PROTECTED]> wrote: This is clearly O(N*N)I will give you an O(N*log(N)) algorithm..Stack sort(Stack S, int N){// N

[algogeeks] Re: How to Sort a Stack in ascending order

2006-05-05 Thread sriram
hi geeks... my query is 1. if the user presses 1,0 should be printed and if the user presses 0,1 should be printed. 2. no usage of conditional statements. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm

[algogeeks] Re: Given an array of size n of 0 and 1 only sort it in linear time.

2006-05-05 Thread shishir
Errata: Should be j in place of i in the condition statement of the for loop. and arr[j]=0 should come before arr[i]=0; Here's the correct code. void sort(int arr[]) { for(int i = 0, j = 0; jhttp://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---

[algogeeks] Re: Given an array of size n of 0 and 1 only sort it in linear time.

2006-05-05 Thread shishir
void sort(int arr[]) { for(int i = 0, j = 0; ihttp://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---

[algogeeks] Re: Median of 2 combined array X[1...n] and Y[1...n] sorted in 0(lgn)

2006-05-05 Thread W Karas
Manu wrote: > Median of 2 combined array X[1...n] and Y[1...n] sorted. > Find o(lgn) algo to find the median of all 2n elements in the 2 array. > > Well I tried and came up with this solution...if somebody has some > other way plz tell..thnx in advance > > we cann't use merging and then find t

[algogeeks] Re: Given an array of size n of 0 and 1 only sort it in linear time.

2006-05-05 Thread W Karas
W Karas wrote: > Manu wrote: > > I know counting sort can do in linear time but we dont need to use and > > extra space. > > as we do in case of counting sort. > > > > > > I came up with this sol. but i think it's not stable so if u can find a > > stable algo plzzz > > > > > > i=0;j=n-1; > >

[algogeeks] Re: Given an array of size n of 0 and 1 only sort it in linear time.

2006-05-05 Thread Cool_Happy
oops i made mistake sorry for that void sort(int *a) { for(int i = 1, j = 0; i a[i]) swap(a[i],a[j]); j++; } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" gro

[algogeeks] Re: Given an array of size n of 0 and 1 only sort it in linear time.

2006-05-05 Thread W Karas
Manu wrote: > I know counting sort can do in linear time but we dont need to use and > extra space. > as we do in case of counting sort. > > > I came up with this sol. but i think it's not stable so if u can find a > stable algo plzzz > > > i=0;j=n-1; > > while(i if(a[i]==a[j]) { >

[algogeeks] Re: Given an array of size n of 0 and 1 only sort it in linear time.

2006-05-05 Thread SIVA SANKARA REDDY
Hi negi!    forget abt stable sort, your code wud not even do simple sort.    e.g. try your code on a[]={0,1,0} , it doesn't sort it as a[j] never > a[i]. cheers, siva.On 5/5/06, Cool_Happy <[EMAIL PROTECTED]> wrote: i think this sort the array in linear time..if this snippet has a

[algogeeks] Re: Given an array of size n of 0 and 1 only sort it in linear time.

2006-05-05 Thread Cool_Happy
hi matia ... i think the code you have written sounds good.. but it is not sorting the array it is a kind of counting number of 1 and 0... how ever you can write a simple code like int one =0; zero =0; for (i=0;ihttp://groups.google.com/group/algogeeks -~--~~~~--~

[algogeeks] Re: Given an array of size n of 0 and 1 only sort it in linear time.

2006-05-05 Thread Manu
Hi Mattia, what u have is just counted the number of 0 and 1 in the given array but u haven't sorted them. what i want u is to sort the array and the sorting should be stable sort as in the case of counting sort. Bye --~--~-~--~~~---~--~~ You received this message

[algogeeks] Re: Given an array of size n of 0 and 1 only sort it in linear time.

2006-05-05 Thread Cool_Happy
i think this sort the array in linear time.. if this snippet has any error do let me know.. void sort(int *a) { for(int i = 1, j = 0; i a[i]) { swap(a[i],a[j]); j++; } } } --~--~-~--~~~---~--~~ You received

[algogeeks] Where can I find JWJ Williams's paper in heapsort

2006-05-05 Thread Kevin Fan
I've searched the google scholar, but find no links. I'm wondering where can I find this paper. This is the first paper in heapsort and is published in Communications of the ACM, 1964 --~--~-~--~~~---~--~~ You received this message because you are subscribed to

[algogeeks] Re: Given an array of size n of 0 and 1 only sort it in linear time.

2006-05-05 Thread Mattia Merzi
On 5/5/06, Manu <[EMAIL PROTECTED]> wrote: > I know counting sort can do in linear time but we dont need to use and > extra space. > as we do in case of counting sort. if the array values are only 0 and 1, assuming that the array contains at best 255 elements, counting sort would need only 3 bytes

[algogeeks] Given an array of size n of 0 and 1 only sort it in linear time.

2006-05-05 Thread Manu
I know counting sort can do in linear time but we dont need to use and extra space. as we do in case of counting sort. I came up with this sol. but i think it's not stable so if u can find a stable algo plzzz i=0;j=n-1; while(ihttp://groups.google.com/group/algogeeks -~--~~---

[algogeeks] Median of 2 combined array X[1...n] and Y[1...n] sorted in 0(lgn)

2006-05-05 Thread Manu
Median of 2 combined array X[1...n] and Y[1...n] sorted. Find o(lgn) algo to find the median of all 2n elements in the 2 array. Well I tried and came up with this solution...if somebody has some other way plz tell..thnx in advance we cann't use merging and then find the median cause that wil

[algogeeks] Re: How to Sort a Stack in ascending order

2006-05-05 Thread Kapil
what you think about radix sort here. Kapil --~--~-~--~~~---~--~~ 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, s

[algogeeks] Re: simulated the behavior of a single ant

2006-05-05 Thread makc.the.great
iwgmsft wrote: > How would you create a program that simulated the behavior of a single > ant that could most effectively navigate its way across a particular > difficult trail? http://groups.google.com/groups/search?q=following+line+group%3A*robotics* --~--~-~--~~~