computer science homework
Problem solving using recursion
There are two skeleton programs, flesh them out following the suggestions given.
Recursive algorithm for calculating xn: if n = 0, return 1.0 else return x * xn-1 (slow technique)
Alternate (faster) algorithm: if n = 0, return 1.0 else if n is odd return x * xn-1 else { y = xn/2; return y * y;} (fast technique).
Run program with several input values and compare results from fast power, slow power, and Math.pow in this table:
Show all digits displayed by your program.
Base | Exponent | slow power | fast power | Math.pow |
3.5 | 64 |
|
|
|
5 | 15 |
|
|
|
1.25 | 31 |
|
|
|
2 | 17 |
|
|
|
String matching
Finding needle in a haystack:
If needle is longer than the haystack then failure
else if needle matches the initial portion of haystack (of same size as the needle) then success
else {
create a shorter haystack (haystack.substring(1))
return result from recursive call on the shorter haystack
}
You are allowed to use only the following methods from the Java String class: .length(), .equals(), .substring().
You are not allowed to use any other method from the String class.
Fill results from power calculation in this page, copy paste source code and screen shots from the two finished programs in the following pages.
Submit the Word document and zipped NetBeans project folders through Isidore assignments.
10 years ago
15
Purchase the answer to view it

- joshua.zip
- PLEASE WRITE TWO ESSAYS 700 WORDS OR MORE IN MLA FORMAT IN WHICH I WILL GIVE YOU THE DETAILS.
- soc6
- Normal Distribution - Amount of Sleep http://www.highbloodpressureinfo.org/images/snoring-cartoon.JPG Do we humans get enough amount of sleep we need?
- Explain at least two (2) ways the rates and forms of violence differ based on culture. Identify at least two (2) reasons why you believe your chosen differences exist.
- bu470 strategic management 170849
- Create a hypothetical organizational philosophy statement. Include a mission statement, vision statement, and core principles/values.
- ECO - Bubba Wildcat has the opportunity to buy a tract of land under 45781
- Please provide an example how long term incentive plans have helped a company meet their strategic goals 161137
- Multiple Questions Answers
- BUSN 427 Global Issues in Business Week 5 DQ 2 Devry