[algogeeks] Re: What algorithm can be used to decide the denomination of notes in an ATM machine?

2009-09-23 Thread eSKay
@Shishir cool! this seems to work!! C[i] = (N-1)/D[i] ; //this is super cool On Sep 21, 10:29 am, Shishir Mittal 1987.shis...@gmail.com wrote: Let the denominations be D[] = {1000,500,100}, and amount be N. Let C[] , denotes the count of each denomination. for ( i=0 ; i 2 ; i++) {        

[algogeeks] Re: What algorithm can be used to decide the denomination of notes in an ATM machine?

2009-09-23 Thread eSKay
@Channa thanks for explaining for the benefit of everybody. On Sep 22, 4:50 pm, Channa Bankapur channabanka...@gmail.com wrote: @eSKay, @Ankur, et al., Please be aware that there are non-Indians too in the group. Hi All, Let me try and define the problem precisely (as far as I can). The

[algogeeks] Re: Form of 3^n

2009-09-23 Thread vicky
ok i can tell one with complexity of O(log(n)) , u take a no. pow = 3,temp=3; then while(1){ temp=pow; pow*=pow; if(pown){ pow=pow/temp; break; } } now do , pow =pow *3; untill pow=n; and check from here am i clear? On Sep 23, 2:40 am, Dave dave_and_da...@juno.com wrote: He didn't

[algogeeks] Re: What algorithm can be used to decide the denomination of notes in an ATM machine?

2009-09-23 Thread eSKay
I disagee. Please don't force your personal opinions on everybody like this. Thanks. On Sep 20, 4:39 pm, ankur aggarwal ankur.mast@gmail.com wrote: i think there is no use of discussing this ques.. On Sun, Sep 20, 2009 at 2:25 PM, eSKay catchyouraak...@gmail.com wrote: yes it is

[algogeeks] Re: Form of 3^n

2009-09-23 Thread Dufus
Vicky, Yup! you got it there. BTW you might like to do binary search again instead of sequential search when you hit the break condition. to indeed make it O(logn). Infact if M=3^n is given then this algo would be of complexity O(log log M) _dufus On Sep 23, 11:59 am, vicky mehta...@gmail.com

[algogeeks] Re: Form of 3^n

2009-09-23 Thread MrM
You can also do it in O(log2(log3(N))) by implementing binary search for power of 3 ! but its slower than normal way for small N's ! On Sep 21, 8:22 pm, Anshya Aggarwal anshya.aggar...@gmail.com wrote: how to find that whether the given number was of the form 3^n. ( i.e. 3 to the power n).

[algogeeks] Re: Form of 3^n

2009-09-23 Thread sharad kumar
isnt his algo same like modular exponentiation in CLRS On Wed, Sep 23, 2009 at 5:09 PM, Dufus rahul.dev.si...@gmail.com wrote: Vicky, Yup! you got it there. BTW you might like to do binary search again instead of sequential search when you hit the break condition. to indeed make it O(logn).

[algogeeks] Re: Form of 3^n

2009-09-23 Thread vicky
yaa , that's right as then we are sure of having complexity O(n) On Sep 23, 4:39 pm, Dufus rahul.dev.si...@gmail.com wrote: Vicky, Yup! you got it there. BTW you might like to do binary search again instead of sequential search when you hit the break condition. to indeed make it O(logn).

[algogeeks] Re: probabiltiy + DP

2009-09-23 Thread vicky
@ Minjie Zha , hey, how does these things clicks to u , as i thought it for 2 hrs. and still couldn't find a completely correct sol.. On Sep 19, 2:04 pm, Minjie Zha diego...@gmail.com wrote: Oh yes, I made a mistake. Your are right. On Sep 18, 12:02 am, ashish gupta ashish12.it...@gmail.com

[algogeeks] Re: Form of 3^n

2009-09-23 Thread Dave
Computing log base 2 is one multiplication simpler than computing log base 3. Dave On Sep 22, 7:49 pm, Prabhu Hari Dhanapal dragonzsn...@gmail.com wrote: is computing  log to the  base 2  simpler than  computing log to the  base 3 ? On Tue, Sep 22, 2009 at 5:40 PM, Dave