Never Judge a Book by Its Cover.............
i can't understand the logic behind it...can u explain further
For each cut, you are guaranteed to be able to intersect all the previous cuts. If you sketch out the first few cuts, you'll see that:p(n) = p(n-1) + (n-1) + 1that is, for any given pizza with n cuts, the maximum number of slices is equal to a pizza with n-1 cuts, plus one slice for every cut that is intersected by the nth cut ( we know that to be n-1 ), plus 1.From this, you get a recurrence that can be solved to give a constant time function:p(n) = p(n-1) + np(n) = (n*(n+1))/2 + 1
Enter your email address below to get
latest articles directly in your inbox:
Delivered by Shipu's Blogspot