willieshi232

Untitled

Apr 20th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. 12.1
  2. 3.
  3. 1
  4. 1, 2
  5. 1, 3
  6. 1, 2, 4
  7. 1, 2, 4, 8, 16
  8. 1, 3, 7, 15, 30
  9. 1, 3, 6, 12, 25, 50, 100
  10. 4.
  11. 113
  12. 140, 70
  13. 168, 84, 42
  14. 120, 60, 30
  15. 160, 80, 40, 20, 10
  16. 5.
  17. *
  18. [*]
  19. ([*])
  20. ([([*])])
  21. [([([*])])]
  22. 12.2
  23. 8.
  24. call stack is the structure of information about all methods that have currently been called by your program. Recursion produces a tall call stack in which each recursive call is represented.
  25. 9. lines would stay in the original order
  26. 10.No base case so it would call its self forever
  27. 12.3
  28. 13.
  29. 6
  30. 4
  31. 7
  32. 0
  33. 1
  34. 14.
  35. 57
  36. 1029
  37. -74
  38. 2438
  39. 132483
  40. 15.
  41. 7
  42. 6
  43. 4
  44. 10
  45. 5
  46. 20.
  47. A image that recursively redraws smaller versions within itself
  48. 21.
  49. public static void drawHexagon(Graphics g, Point position, int size) {
  50. Polygon poly = new Polygon();
  51. poly.addPoint(position.x, position.y + size / 2);
  52. poly.addPoint(position.x + size / 3, position.y);
  53. poly.addPoint(position.x + 2 * size / 3, position.y);
  54. poly.addPoint(position.x + size, position.y + size / 2);
  55. poly.addPoint(position.x + 2 * size / 3, position.y + size);
  56. poly.addPoint(position.x + size / 3, position.y + size);
  57. g.drawPolygon(poly);
  58. }
  59. 22.
  60. Recursion is an effective way to implement a backtracking algorithm because the memory of decisions and points to go back to are represented by the recursive call stack. The pattern of "choose, explore, un-choose is elegantly represented by recursive calls for each individual choice.
  61. 23.
  62. A decision tree is a description of the set of choices that can be made by a recursive backtracking method at any point in the algorithm.
  63. 25.
  64. moves: NE N
  65. moves: N NE
  66. moves: N N E
  67. moves: N E N
  68. moves: E N N
Advertisement
Add Comment
Please, Sign In to add comment