cs102_lab7

Lab 7 - Recursion

  1. Write a recursive method that takes a decimal value as an int parameter and prints out the binary equivalent of it on the console. E.g., if your method is passed the integer value 5 (decimal) it should print 101 (binary). void printInBinary(int decimalValue)
  2. Redo the above so that it returns the result as a String, rather than directly printing it on the console. String convertToBinary(int decimalValue)
  3. Write a method to do the inverse, that is, given a binary number (as a String), return the corresponding decimal int value.
 int convertToDecimal(String binaryValue)
  4. Implement selection sort using recursion. void selectionSort(Comparable[] list)
  5. Implement binary search using recursion (returns the index).
 int binarySearch(Comparable[] sortedList, Comparable target)
cs102_lab7.txt · Last modified: 2012/11/27 16:46 by bgedik

Page Tools