it's a simple dp , ned not be knapsack one.

int arr[n];
arr[0]=0
arr[1]=1;

for(int i=2;i<=n;i++)
{
arr[i]=arr[i-1]+arr[i-2];
}

do you get the code ? i mean , pseudo code was almost similar.


On Sun, Aug 14, 2011 at 1:34 AM, sagar pareek <sagarpar...@gmail.com> wrote:

> Sorry 4 above post i thought it a diff ques
>
>
> On Sun, Aug 14, 2011 at 1:33 AM, sagar pareek <sagarpar...@gmail.com>wrote:
>
>> its n/2+1
>>
>>
>> On Sat, Aug 13, 2011 at 8:45 PM, Puneet Goyal <puneetgoya...@gmail.com>wrote:
>>
>>> I think it's fibonacci series...
>>> T(n)= T(n-1) + T(n-2)
>>>
>>> Explanation:
>>> T(n): no. of ways for n stairs
>>>
>>> T(n-1): when it took the first step as 1 stair
>>>
>>> t(n-2): when it took the first step as 2 stairs
>>>
>>> the series can be started as
>>> T(1)=1
>>> T(2)=2
>>> and calculate the rest from above
>>>
>>> On Sat, Aug 13, 2011 at 8:37 PM, Gaurav Menghani <
>>> gaurav.mengh...@gmail.com> wrote:
>>>
>>>> Knapsack DP
>>>>
>>>> On Sat, Aug 13, 2011 at 8:35 PM, Kamakshii Aggarwal
>>>> <kamakshi...@gmail.com> wrote:
>>>> > yes
>>>> >
>>>> > On Sat, Aug 13, 2011 at 8:30 PM, Puneet Goyal <
>>>> puneetgoya...@gmail.com>
>>>> > wrote:
>>>> >>
>>>> >> 1 or 2 stairs?
>>>> >>
>>>> >> On Sat, Aug 13, 2011 at 8:24 PM, Kamakshii Aggarwal
>>>> >> <kamakshi...@gmail.com> wrote:
>>>> >>>
>>>> >>> Given n stairs, how many number of ways can you climb if u use
>>>> either 1
>>>> >>> or 2 at a time?
>>>> >>> --
>>>> >>> 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.
>>>> >>
>>>> >>
>>>> >>
>>>> >> --
>>>> >>
>>>> -----------------------------------------------------------------------
>>>> >> Puneet Goyal
>>>> >> Student of B. Tech. III Year (Software Engineering)
>>>> >> Delhi Technological University, 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,
>>>> > 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.
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Gaurav Menghani
>>>>
>>>> --
>>>> 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.
>>>>
>>>>
>>>
>>>
>>> --
>>> -----------------------------------------------------------------------
>>> Puneet Goyal
>>> Student of B. Tech. III Year (Software Engineering)
>>> Delhi Technological University, 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
>> SAGAR PAREEK
>> COMPUTER SCIENCE AND ENGINEERING
>> NIT ALLAHABAD
>>
>>
>
>
> --
> **Regards
> SAGAR PAREEK
> COMPUTER SCIENCE AND ENGINEERING
> NIT 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.
>



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

Reply via email to