Saturday, January 9, 2010

Freecycling

People amass a lot of things , but use a very few of them in their wonted day-to-day life. Human desire for materialistic needs is colossal and one is free to own whatever one needs. It doesn't stop there , he even duplicates a lot of stuff and continues to hoard as a result of his "brand-new" disease. Consequently, the unused stuff mostly finds its place in the trash or is hastily set into flames or recycled . One should remember that the latter of the three is always associated with a cost either directly or indirectly.

How about giving it to someone for further use of its remaining shelf-life, for free of cost ?
Yes. It will prevent land fills and land waste. Start to freecycle.

Can you freecycle anything or everything ?
Yes. But there are some exceptions and depends on one's own free will.

How does one freecycle ?
Although, one might have already done freecycling at some point in their life, the freecycle community opens up a lot of possibilities. To know more about the same visit www.freecycle.org . To start freecycling , just join the freecycle yahoo groups in your area.

Thursday, January 7, 2010

Implement Push,Pop and finding minimum element on a stack

How do you write a method for push(),pop(),minelement() of stack in O(1) time ?

Algorithm - List all Possible Ways

Given a number 'n' means n*2 opening, closing parentheses can exist , out of which n are opening and n are closing. These parentheses are used for the same purpose of forming an arithmetic expression following the general rule that

1)An opening bracket should have a corresponding closing bracket
2)There must be equal number of opening and closing brackets
3)The expression formed should be valid in terms of nesting of parentheses.

We have to determine the number of possible expressions you can generate using these parenthesis.

Ex: say n = 4 , means there can be 4 opening and 4 closing parentheses.
and the different ways are given below(The variable/numbers inside the parentheses are ignored since they are not important)

( ) ( ) ( ) ( )
( ( ) ) ( ( ) )
( ) ( ( ) ) ( )
( ( ) ) ( ) ( )
( ) ( ) ( ( ) )
( ) ( ( ( ) ) )
( ( ( ) ) ) ( )

Devise a method which would determing the possible ways for any 'N'