Блог пользователя __abs

Автор __abs, 2 года назад, По-английски

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)$$$
  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Lucky