Question: 1. Given a string, compute recursively a new string where all appearances of pi have been replaced by 3.14. E.g. input string pipi, output

1. Given a string, compute recursively a new string where all appearancesof "pi" have been replaced by "3.14". E.g. input string pipi, outputstring : 3.143.14, input string pip, output string : 3.14p (6 points)2. Prove that the following function always returns the reversed form ofstr: (6 points) string reverse (string str) { if (str.length() 3. Given

1. Given a string, compute recursively a new string where all appearances of "pi" have been replaced by "3.14". E.g. input string pipi, output string : 3.143.14, input string pip, output string : 3.14p (6 points) 2. Prove that the following function always returns the reversed form of str: (6 points) string reverse (string str) { if (str.length() 3. Given the following pseudocode which takes a number as input, explain what the given function would return. function recursive Fn (num): if num == 0: return 0 else: = num 2 y = int (num / 2) return x + 10 * recursive Fn(y) Furthermore, give the return value when input is : a. 5 b. 16 C. 23 (6 points) - 4. Prove that the following code snippet outputs 2n+1 1: int sumPowers2 (int n) { int sum = 0 %; int i = 0 %; while (i 5. A sequence is defined recursively by a = 1, a2 = 4, a a n = a n-1 - a + a n-2 n-3 1 + 2(2n- 3). Prove that a n = 9, and 3 2 = n for all n 1. (6 points)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!