CIS 265 Homework 3 Due: Th. Mar 19th Fall 2015 â Prof. Matos
Transcription
CIS 265 Homework 3 Due: Th. Mar 19th Fall 2015 â Prof. Matos
CIS 265 Fall 2015 – Prof. Matos Homework 3 Due: Th. Mar 19th Provide a recursive solution to any one of the following problems. Problem 18.23 [10 points] (Binary to decimal) Write a recursive method that parses a binary number as a string into a decimal integer. The method header is: public static int bin2Dec(String binaryString) Write a test program that prompts the user to enter a binary string and displays its decimal equivalent. Test your program with the following values: 1001, 1011, 1111111111111111 Problem 18.25 [10 points] (String permutation) Write a recursive method to print all the permutations of a string. For example, for the string abc, the permutation is: abc, acb, bac, bca, cab, cba Test your program with the following values: “xyz”, “12345” [10 Points] (Sorting Geometric Objects). This problem is based on Homework2. After the list of geometric objects is created from the raw data stored in disk, you need to recursively sort the list and print its elements in ascending order of area values. [15 Points]. [A Variation of the Knight’s Tour] Assume a normal 8x8 chess board. Designate a cell as ‘Destination’. Position a Knight on any cell of the chess board. Print a path leading from the knight’s starting position to the ‘Destination’ cell.