## Class Recursive

• java.lang.Object
• Recursive

• ```public class Recursive
extends java.lang.Object```
• ### Field Summary

Fields
Modifier and Type Field and Description
`static int` `BOARD_SIZE`
The size of the Sudoko board.
`static int` `MINI_SIZE`
The size of a mini marix on the Sodoko board.
• ### Constructor Summary

Constructors
Constructor and Description
`Recursive()`
• ### Method Summary

Methods
Modifier and Type Method and Description
`boolean` ```canFlowOffMap(int[][] map, int row, int col)```
Problem 8: Determine if water at a given point on a map can flow off the map.
`void` ```drawCarpet(int size, int limit)```
Problem 6: Draw a Sierpinski Carpet.
`void` ```drawTriangles(int windowSize, int minSideLength, int startingSideLength)```
Problem 5: Create a DrawingPanel and place Sierpinski triangles in it.
`java.lang.String` `getBinary(int n)`
Problem 1: convert a base 10 int to binary recursively.
pre: n >= 0
post: Returns a String that represents N in binary.
`int[][]` `getSudokoSolution(int[][] startBoard)`
Problem 7: Find a solution to a Sudoko puzzle.
`java.util.ArrayList<java.lang.String>` `listMnemonics(java.lang.String number)`
Problem 4: Find all combinations of mnemonics for the given number.
pre: number != null, all characters in number are digits
post: see tips section of assigment handout
`int` ```minDifference(int numTeams, int[] abilities)```
Problem 9: Find the minimum difference possible between teams based on ability scores.
`int` `nextIsDouble(int[] data)`
Problem 3: Returns the number of elements in data that are followed directly by value that is double that element.
`java.lang.String` `revString(java.lang.String stringToRev)`
Problem 2: reverse a String recursively.
pre: stringToRev != null
post: returns a String that is the reverse of stringToRev
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Field Detail

• #### BOARD_SIZE

`public static final int BOARD_SIZE`
The size of the Sudoko board. Value will be a perfect square greater than 0.
Constant Field Values
• #### MINI_SIZE

`public static final int MINI_SIZE`
The size of a mini marix on the Sodoko board.
• ### Constructor Detail

• #### Recursive

`public Recursive()`
• ### Method Detail

• #### getBinary

`public java.lang.String getBinary(int n)`
Problem 1: convert a base 10 int to binary recursively.
pre: n >= 0
post: Returns a String that represents N in binary. All chars in returned String are '1's or '0's. Most significant digit is at position 0
Parameters:
`n` - the base 10 int to covnert to base 2
• #### revString

`public java.lang.String revString(java.lang.String stringToRev)`
Problem 2: reverse a String recursively.
pre: stringToRev != null
post: returns a String that is the reverse of stringToRev
Parameters:
`stringToRev` - the String to reverse.
• #### nextIsDouble

`public int nextIsDouble(int[] data)`
Problem 3: Returns the number of elements in data that are followed directly by value that is double that element. pre: data != null post: return the number of elements in data that are followed immidiately by double the value
• #### listMnemonics

`public java.util.ArrayList<java.lang.String> listMnemonics(java.lang.String number)`
Problem 4: Find all combinations of mnemonics for the given number.
pre: number != null, all characters in number are digits
post: see tips section of assigment handout
Parameters:
`number` - The number to find mnemoics for
• #### drawTriangles

```public void drawTriangles(int windowSize,
int minSideLength,
int startingSideLength)```
Problem 5: Create a DrawingPanel and place Sierpinski triangles in it. The lower left corner shall be 20 pixels from the left edge of the window and 20 pixels from the bottom of the window.
Parameters:
`windowSize` - > 20
`minSideLength` - > 4
`startingSideLength` - > minSideLength
• #### drawCarpet

```public void drawCarpet(int size,
int limit)```
Problem 6: Draw a Sierpinski Carpet.
Parameters:
`size` - the size in pixels of the window
`limit` - the smallest size of a sqauer in the carpet.
• #### getSudokoSolution

`public int[][] getSudokoSolution(int[][] startBoard)`
Problem 7: Find a solution to a Sudoko puzzle.
pre: board != null, board is 9 by 9.
post: return a board that is the solved puzzle or a copy of the original board if there is no solution
Parameters:
`startBoard` - The starting board. Empty values = 0, given values = 1 through 9 may not be changed
• #### canFlowOffMap

```public boolean canFlowOffMap(int[][] map,
int row,
int col)```
Problem 8: Determine if water at a given point on a map can flow off the map.
pre: map != null, map.length > 0, map is a rectangular matrix, 0 <= row < map.length, 0 <= col < map[0].length
post: return true if a drop of water starting at the location specified by row, column can reach the edge of the map, false otherwise.   * @param map The elevations of a section of a map.
Parameters:
`row` - The starting row of a drop of water.
`col` - The starting column of a drop of water.
• #### minDifference

```public int minDifference(int numTeams,
int[] abilities)```
Problem 9: Find the minimum difference possible between teams based on ability scores. The number of teams may be greater than 2. The goal is to minimize the difference between the team with the maximum total ability and the team with the minimum total ability.
pre: numTeams >= 2, abilities != null, abilities.length >= numTeams
post: return the minimum possible difference between the team with the maximum total ability and the team with the minimum total ability.
Parameters:
`numTeams` - the number of teams to form. Every team must have at least one member
`abilities` - the ability scores of the people to distribute The return value will be greater than or equal to 0.