Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Edit: The answer should have these numbers like in the paper. C# Programming. I want the right code in the commented area so that they

Edit: The answer should have these numbers like in the paper.image text in transcribed

C# Programming.

I want the right code in the commented area so that they can have the same values as the Recursive. Let me know if nothing is clear.

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace Recursive_Exercise_Set_1 { class Program { static void Main(string[] args) { Console.WriteLine("Problem 1 recursive"); for (int n = 21; n > 1; n -= 3) Console.WriteLine("n = {0}, f()={1}", n, oneC(n)); Console.WriteLine("Problem 1 iterative"); for (int n = 21; n > 1; n -= 3) Console.WriteLine("n = {0}, f()={1}", n, oneD(n)); Console.WriteLine("Problem 2 recursive"); for (int n = 8; n >= 0; n -= 2) Console.WriteLine("n = {0}, f()={1:n0}", n, twoC(n)); Console.WriteLine("Problem 2 iterative"); for (int n = 8; n >= 0; n -= 2) Console.WriteLine("n = {0}, f()={1:n0}", n, twoD(n)); Console.WriteLine("Problem 3 recursive"); for (int n = 199; n >= 0; n -= 33) Console.WriteLine("n = {0}, f()={1:n0}", n, threeC(n)); Console.WriteLine("Problem 3 iterative"); for (int n = 199; n >= 0; n -= 33) Console.WriteLine("n = {0}, f()={1:n0}", n, threeD(n)); Console.WriteLine("Problem 4 recursive"); for (int n = 10; n >= 1; n -= 2) Console.WriteLine("n = {0},{1} f()={2:n0}", n / 2, n / 3, fourC(n / 2, n / 3)); Console.WriteLine("Problem 4 iterative"); for (int n = 10; n >= 1; n -= 2) Console.WriteLine("n = {0},{1} f()={2:n0}", n / 2, n / 3, fourD(n / 2, n / 3)); }

static int oneC(int n) { int result; if (n == 0 | n == 1) result = n;

else result = n + oneC(n - 2);

return result; }

static int oneD(int n) {

//HERE }

static int twoC(int n) { int result; if (n == 0) result = 1;

else result = 3 * twoC(n - 1);

return result; }

static int twoD(int n) { int i; int result = 1;

for (i = 1; i

static int threeC(int n) { int result; if (n

else result = 1 + threeC(n/2);

return result; }

static int threeD(int n) { //HERE }

static int fourC(int a, int b) { int result; if (a == 0 ) result = 1;

else result = b * fourC(a - 1, b);

return result; }

static int fourD(int a, int b) { //HERE } }

}

Fill in the missing code from project Recursive Exercise Set 1. Print only methods one through fourD and output. C# code first, then output. All code turned in for this class must have a minimum of 10 font size in portrait. Output should be on one sheet of paper by itself. Problem 1 recursive f (21) = 121 f(18) = 90 f(15) = 64 f (12) = 42 f (9) = f (6) = f(3) = 4 Problem 2 recursive f(8) = 6,561 f(6) = 729 f (4) = 81 f (2) = 9 f(0) = 1 Problem 3 recursive f (199) = 7 f(166) = 7 f(133) = 7 f(100) = f(67) = 6 f(34) = 5 f(1) = 0 Problem 4 recursive f (5,3) = 243 f (4,2) = 16 f(3,2) = 8 (2,1)= 1 f(1,0) = 0 o una au Problem 2 iterative f (8) = 6,561 f(6) = 729 f (4) = 81 f(2)= f(0) = Problem 1 iterative f (21) = 121 f(18) = 90 f(15) = 64 f (12) = 42 f(9) = 25 f(6) = f(3) = Problem 4 iterative f(5,3) = 243 f(4,2) = 16 f(3, 2) = 8 f(2, 1) = 1 (1,0)= 0 Problem 3 iterative f(199) = 7 f(166) = 7 f(133) = 7 f(100) = 6 f(67) = 6 f(34) = f(1) = o Fill in the missing code from project Recursive Exercise Set 1. Print only methods one through fourD and output. C# code first, then output. All code turned in for this class must have a minimum of 10 font size in portrait. Output should be on one sheet of paper by itself. Problem 1 recursive f (21) = 121 f(18) = 90 f(15) = 64 f (12) = 42 f (9) = f (6) = f(3) = 4 Problem 2 recursive f(8) = 6,561 f(6) = 729 f (4) = 81 f (2) = 9 f(0) = 1 Problem 3 recursive f (199) = 7 f(166) = 7 f(133) = 7 f(100) = f(67) = 6 f(34) = 5 f(1) = 0 Problem 4 recursive f (5,3) = 243 f (4,2) = 16 f(3,2) = 8 (2,1)= 1 f(1,0) = 0 o una au Problem 2 iterative f (8) = 6,561 f(6) = 729 f (4) = 81 f(2)= f(0) = Problem 1 iterative f (21) = 121 f(18) = 90 f(15) = 64 f (12) = 42 f(9) = 25 f(6) = f(3) = Problem 4 iterative f(5,3) = 243 f(4,2) = 16 f(3, 2) = 8 f(2, 1) = 1 (1,0)= 0 Problem 3 iterative f(199) = 7 f(166) = 7 f(133) = 7 f(100) = 6 f(67) = 6 f(34) = f(1) = o

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

More Books

Students also viewed these Databases questions