Re: [algogeeks] repeating numbers in an array

2010-10-02 Thread kusuma sanjeev
array elements: 1 2 9 8 7 5 2 3 1 1 4 2 6 2 3 sort: 1 1 1 2 2 2 2 3 3 4 5 6 7 8 9 compare the element with the next , if its same then increment the count. repeat until v find all the occurrences of tat element & then insert tat element into arr[count] (if arr[count] is null else traverse the list

Re: [algogeeks] repeating numbers in an array

2010-10-02 Thread mac adobe
how will this give me array_1 which lists all numbers comming 1 time , array_2 which lists all numbers comming 2 time etc ? On Sun, Oct 3, 2010 at 11:31 AM, kusuma sanjeev wrote: > One possible solution would be to create an array of pointers to the list.. > array index indicates how many time

Re: [algogeeks] repeating numbers in an array

2010-10-02 Thread kusuma sanjeev
One possible solution would be to create an array of pointers to the list.. array index indicates how many times the element occurs and the list gives the elements. On Sun, Oct 3, 2010 at 11:22 AM, sharad kumar wrote: > it will take same amount of memory nakey value is element and vaule is >

Re: [algogeeks] repeating numbers in an array

2010-10-02 Thread sharad kumar
it will take same amount of memory nakey value is element and vaule is the amount of times element occurs. On Sun, Oct 3, 2010 at 11:11 AM, mac adobe wrote: > i think hash map takes lots of memory ... please correct me if i am wrong > here .. > > anyways its a soluton but i would like t

Re: [algogeeks] repeating numbers in an array

2010-10-02 Thread mac adobe
i think hash map takes lots of memory ... please correct me if i am wrong here .. anyways its a soluton but i would like to have a different solution .. :) --mac On Sun, Oct 3, 2010 at 10:55 AM, sharad kumar wrote: > cant u use a hash map buddy??? > > On Sun, Oct 3, 2010 at 10:35 AM, mac adobe

Re: [algogeeks] repeating numbers in an array

2010-10-02 Thread sharad kumar
cant u use a hash map buddy??? On Sun, Oct 3, 2010 at 10:35 AM, mac adobe wrote: > You are given a very long array of integers . Some number in this integer > array come 1 time , some 2 times some 3 times . create 3 different arrays . > > Array 1 will have numbers with numbers comming only1 time

[algogeeks] repeating numbers in an array

2010-10-02 Thread mac adobe
You are given a very long array of integers . Some number in this integer array come 1 time , some 2 times some 3 times . create 3 different arrays . Array 1 will have numbers with numbers comming only1 time , Array 2 will have numbers with numbers comming 2 times, Array 3 will have numbers with n

[algogeeks] Re: Sort in Linear time O(n)

2010-10-02 Thread Gene
Radix sort _is_ dependent on the length of keys. If the radix is R, then the sort must make ceiling(log_R(k)) passes over the data. Increasing the R to decrease the number of passes has a storage cost: you need R buckets. On Oct 2, 3:04 pm, Mridul Malpani wrote: > Radix sort is independent of th

[algogeeks] Re: Sort in Linear time O(n)

2010-10-02 Thread Gönenç Ercan
As far as I know; Count sort is O(n+M) where M is the maximum value. Radix sort is O((n+c)k) where k is the number of digits and c is the cost of sorting a digit. So in this case if the number were represented as binary it would be 2, so k = log_2(n^3) = 3logn and c=2. So the complexity would be O(

[algogeeks] Re: Sort in Linear time O(n)

2010-10-02 Thread Mridul Malpani
Radix sort is independent of the range and only depends on the number of items. here k=max value= n^3. since , radix sort is independent of k, so here also it sorts "n integers" in O(n). On Oct 2, 10:38 pm, "Harshal ..Bet oN iT!!" wrote: > this theorem is true for comparision sorts only! cou

Re: [algogeeks] Sort in Linear time O(n)

2010-10-02 Thread Harshal ..Bet oN iT!!
this theorem is true for comparision sorts only! counting sort is not a comparison sort. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send ema

Re: [algogeeks] Sort in Linear time O(n)

2010-10-02 Thread Shreyas
There is a theorem which states that a sorting algorithm must take o(nlogn) to sort a list of any possible values. however there are certain sorts like insertion sort where o(n) in the best case ie when a list is sorted. On 02-Oct-2010, at 10:32 PM, "Harshal ..Bet oN iT!!" wrote: > you are gi

Re: [algogeeks] Sort in Linear time O(n)

2010-10-02 Thread Harshal ..Bet oN iT!!
but the range (k) is cubic in n, if we use counting sort also in radix sort, k wont be of the order n, so how can solution be in linear time? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googl

Re: [algogeeks] Re: apple problem

2010-10-02 Thread Anand
Since in our case starting point is fixed "ie top left corner" so dynamic programmng will not make any difference. Dynamic programing makes difference only when starting point is not fixed. Solution from Greedy and Dynamic programming will be same in this case. Correct me if I am wrong On Sat, Oct

Re: [algogeeks] Sort in Linear time O(n)

2010-10-02 Thread vaibhav shukla
use radix sort On Sat, Oct 2, 2010 at 10:32 PM, Harshal ..Bet oN iT!! wrote: > you are given n integers in the range 0 to n3-1 ((n to the power 3) - 1) . > how can u sort the numbers in O(n)? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks

[algogeeks] Sort in Linear time O(n)

2010-10-02 Thread Harshal ..Bet oN iT!!
you are given n integers in the range 0 to n3-1 ((n to the power 3) - 1) . how can u sort the numbers in O(n)? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe fro

Re: [algogeeks] iTS aLL gOOGLE- iNTERVIEW

2010-10-02 Thread Harshal ..Bet oN iT!!
2) We need to find the all complete binary trees using 3 of the (+,*,/,-) at a time as internal nodes and n1,n2,n3,n4 as leaves, and then inorder traversal of the tree. If it is 24 then success. 3)You can view the problem as contructing a binary tree at each stage, either down or right. Count t

[algogeeks] Re: apple problem

2010-10-02 Thread Mridul Malpani
@ anand: the code u have given is an greedy approach. & it will not work. On Oct 1, 12:34 am, Anand wrote: > Here is a code for solving the problem using DP.http://codepad.org/AoPtCmwA > > On Thu, Sep 30, 2010 at 3:01 AM, Modeling Expert < > > cs.modelingexp...@gmail.com> wrote: > > recurssion...

Re: [algogeeks] Re: iTS aLL gOOGLE- iNTERVIEW

2010-10-02 Thread swayambhoo jain
Are the four numbers in question #2 integers or they can be anything? On Sat, Oct 2, 2010 at 10:03 AM, swayambhoo jain wrote: > What about the case when we have repeated numbers in a sequence. > > > On Sat, Oct 2, 2010 at 8:30 AM, bittu wrote: > >> >> > If a person dials a sequence of numbers o

Re: [algogeeks] Re: iTS aLL gOOGLE- iNTERVIEW

2010-10-02 Thread swayambhoo jain
What about the case when we have repeated numbers in a sequence. On Sat, Oct 2, 2010 at 8:30 AM, bittu wrote: > > > If a person dials a sequence of numbers on the telephone, what > > possible words/strings can be formed from the letters associated with > > those numbers? > > > answer should be a

Re: [algogeeks] ATM machine---Google Question

2010-10-02 Thread ankur aggarwal
did not get this question... ?? explain plz.. On Sat, Oct 2, 2010 at 6:52 PM, bittu wrote: > as we know that each user has only 4 digit acc . no.we hav billions of > user wat is maximum bounds on these no. wat algo used to generate 4 > digit uniqe no. & wat is the posible 4 digit no. we can hav

Re: Fwd: [algogeeks] Prim's algorithm using min heap

2010-10-02 Thread Rashmi Shrivastava
Ohh sorry soundar, i forget to send the link...he he,chk this,it may help u... http://www.oronno.co.cc/oronno-presented/Prims_Algorithm_on_MST.pdf http://programminggeeks.com/c-code-for-prims-algorithm/

[algogeeks] Re: iTS aLL gOOGLE- iNTERVIEW

2010-10-02 Thread bittu
> If a person dials a sequence of numbers on the telephone, what > possible words/strings can be formed from the letters associated with > those numbers? answer should be as the maximum bounds isfor simple mobile phone 6 key are having 3 character so n!*(3*n) and 2 keys has 4 charcater

[algogeeks] ATM machine---Google Question

2010-10-02 Thread bittu
as we know that each user has only 4 digit acc . no.we hav billions of user wat is maximum bounds on these no. wat algo used to generate 4 digit uniqe no. & wat is the posible 4 digit no. we can have... Regards Shashank Mani -- You received this message because you are subscribed to the Google

[algogeeks] iTS aLL gOOGLE- iNTERVIEW

2010-10-02 Thread bittu
If-a-person-dials-a-sequence-of-numbers-on-the-telephone-what-possible- words-strings-can-be-formed-from-the-letters We are given 4 numbers say n1, n2, n3, n4. We can place them in any order and we can use mathematical operator +, -, *, / in between them to have final result as 24. Write an algori

[algogeeks] [Yahoo]Implementing Orkut Functionality

2010-10-02 Thread amit
if you click on any orkut member's name you will notice the relationship graph for both of you indicating through whom you are interconnected or in certain cases you won't get this path. if you have to propose algorithm what would be the one ... -- You received this message because you are subsc