__abs's blog

By __abs, 22 months ago, In English

1.

This solution uses a break statement at the end of for(int i=0; i<n; i++) loop (just after mask -= (1<<i)).
How to "prove" that this break still allows all cases to be tested?

What are some other problems that have this?

2.

What is the time complexity (closed form?)?
My take:
If $$$T(k)$$$ is the time complexity when there are $$$k$$$ zeroes in the mask, then

$$$T(k) = (k-1)T(k-2) + O(n)$$$

(as there are (k-1) choices for j)
Required: $$$T(n)$$$.

$$$T(n) = (n-1)(n-3)...(1) + O(k^2 n)$$$

If that break is removed, then

$$$T(k) = {k \choose 2}T(k-2) + O(n^2)$$$
  • Vote: I like it
  • +8
  • Vote: I do not like it

| Write comment?
»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Lucky