Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA (please give a specific answer to the question, not just show program) We want to measure the elapsed time for these computations, so heres

JAVA (please give a specific answer to the question, not just show program)

We want to measure the elapsed time for these computations, so heres some timer code:

long t1 = System.currentTimeMillis();

// do something that requires a lot of time

long t2 = System.currentTimeMillis();

System.out.println("The elapsed time is " + ( t2 - t1 ) / 1000. + " seconds.");

The two methods are

public int factorial_loop(int n){}

public int factorial_recursive(int n){}

Determine the largest input value n for which a factorial can be computed using int.

What was the largest result for factorial using int? n = 16

n! = 2004189184

What was the elapsed time computing this factorial using loops? t = 0

Change the data type to long and repeat the above tests. n = 20

n! = 2432902008176640000

What was the elapsed time computing this factorial using loops? t = 0

What is the elapsed time computing this factorial using recursion? t = 0 PLEASE ANSWER FROM HERE:

Are these times significantly different? Why or why not? Answer in the space below:

Change the data type to BigInteger. Can you find a value for which it requires 1.0 seconds to compute the factorial? Give the number of digits in v, not the number itself.

Number of digits in v =

Palindromes

A palindrome is a word or sentence that reads the same forwards as it does backwards. Letter case and punctuation are always ignored. Spaces are ignored in ordinary palindromes but not in strict ones.

racecar a word that is a palindrome.

Able was I, ere I saw Elba! a strict palindrome (spaces count) attributed to Napoleon.

A man, a plan, a canal: Panama! an ordinary palindrome; spaces are ignored.

2445442 a palindromic number.

There are lots of ways to see if a String is or is not a palindrome. What would be a recursivealgorithm to determine whether or not a String is a palindrome?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Entity Alignment Concepts Recent Advances And Novel Approaches

Authors: Xiang Zhao ,Weixin Zeng ,Jiuyang Tang

1st Edition

9819942527, 978-9819942527

More Books

Students also viewed these Databases questions

Question

use the least-squares regression line to make predictions.

Answered: 1 week ago