This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: very little additional space other than the array itself. For example, you can use an additional variable variable or two, but you cannot use an additional array of storage. State any assumptions you make. CprE 310 Homework 4 21 Feb 2008, in class Problem 4.5 Give a recursive algorithm that counts the number of ones in a bit array. Assume that the inputs to the algorithm are the bit array B , and its length n . You can assume that the array B is indexed from 0 to n-1. Problem 4.6 For the Towers of Hanoi problem described in class, give a recursive algo-rithm that moves n disks ( n is an integer greater than 0) from tower A to tower C using tower B as a buer. Analyze the number of moves taken by the algorithm to move n disks, and prove your result (for the number of moves) using mathematical induction. 2...
View Full Document
- Spring '08