Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started