Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a recursive method called pi_approximation(n) that calculates the Leibniz approximation of given below. Note that you will need to multiply the result by 4

  1. Write a recursive method called pi_approximation(n) that calculates the Leibniz approximation of given below. Note that you will need to multiply the result by 4 to get the approximation of .

image text in transcribed

Note that the nth term can be calculated as image text in transcribed

  1. Write a recursive method called lengthOfLongestSubsequence(a, b) that calculates the length of the longest common subsequence (lcs) of two strings. For example, given the two strings aaacommonbbb and xxxcommonzzz the lcs is common which is 6 characters long so your function would return 6. The length of the lcs of two strings a & b can be calculated as follows:

0 if the length of a or b is 0

1 + lcs(a[1-], b[1-]) if a[0]=b[0]

max(lcs(a,b[1-]), lcs(a[1-],b)) in all other cases

where a[1-] is the string with the first character removed. You only need to return the length of the longest common subsequence. You do not need to find the longest common sequence.

image text in transcribed

// Project 4 pi_approximation (int m) public static double pi_approximation(int n) return ; // Project 4 longestSubsequence (String s) public static int lengthof LongestSubsequence(String a, String b) return

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

Step: 3

blur-text-image

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

Transactions On Large Scale Data And Knowledge Centered Systems X Special Issue On Database And Expert Systems Applications Lncs 8220

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2013th Edition

3642412203, 978-3642412202

Students also viewed these Databases questions

Question

14.1 Goodness-of-Fit Tests: Specified Probabilities

Answered: 1 week ago

Question

6. Identify seven types of hidden histories.

Answered: 1 week ago

Question

What is the relationship between humans and nature?

Answered: 1 week ago