Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This was part of HW #1
- Implement recursive permutations generator.
- Make sure your output matches "out.txt"
- Note: useful STL trick:
- std::vector< std::vector<int> > vv( 10, std::vector<int>(3,0));
- create a vector of 10 vectors with 3 zero's:
- 0,0,0
- 0,0,0
- 0,0,0
- 0,0,0
- 0,0,0
- 0,0,0
- 0,0,0
- 0,0,0
- 0,0,0
- 0,0,0
- submit:
- perm-recursive.h
- perm-recursive.cpp
- Implement non-recursive subset generator based on bits. You may use "int" to
- store bits. This limits your implementation to 32 bits, but as we discussed in
- class it's enough for all real-life problems.
- Submit:
- subsets-bits.cpp
- subsets-bits.h
- //Hw#2
- Prove correctness of the algorithm:
- Fast exponentiation:
- AL4(A, M)
- 1. B := A
- 2. E := M
- 3. R := 1
- 4. while (E > 0) {
- 5. if (E is odd) {
- 6. R := R * B
- 7. E := E - 1
- 8. }
- 9. else {
- 10. B := B * B
- 11. E := E / 2
- 12. }
- 13. }
- 11. return R
- invariant A^M = R_k * ( B_k ^ E_k )
- prove that R = A^M.
- // hw#3
- Problem 5.
- Convert to a homogeneous recurrence and solve using characteristic
- equation:
- T(n) = 2T(n-1) + 3*2^n
- T(0) = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement