# Essay Paper Assignment Help- Computer Science

Q1.Design an iterative algorithm to multiply odd integers. For example, if a given n is an odd integer, then the product is 1 * 3 * 5 * 7 * … * n; if n is an even integer, then the product is 1 * 3 * 5 * 7 * … * (n-1).

Q2.mplement your above iterative algorithm in Java with the following method header.

public static int oddProduct(int n)

public class Main

{

public static int oddProduct(int n)

{

int i = 1;

int product = 1;

if(i%2==0)

{

while(i<(n-1))

{

product*=i;

i+=2;

}

}

else{

while(i<(n))

{

product*=i;

i+=2;

}

}

}

public static void main(String[] args)

{

int product;

int n = 9;

product= oddProduct(n);

System.out.println(product);

}

}

Response Feedback:

off by one

Q3.Design a recursive algorithm to multiply odd integers as specified in the previous question (Q1).

Q4.

Implement your above recursive algorithm in Java with the following method header:

public static int oddProduct(int n)

public class Main

{

public static int oddProduct(int n)

{

if (n == 1)

return 1;

else

return n*oddProduct(n-2);

}

public static void main(String[] args)

{

int product;

int n = 9;

product= oddProduct(n);

System.out.println(product);

}

}

Response Feedback:

What if n is even?

Q16.

Solve the recurrence relation using master’s theorem: T(n) = 9T(n/3) + n. Show all steps.

Q17.

Q19.

You just realized that homework for CPS 340 is due in just 8 hours, yet you have not started. There are four questions in the homework, and each question with different points require certain number of hours to complete (see below). Use a brute-force strategy to maximize your points for the homework.

hours left – 8

hours -[1,5,3,4]

points -[15,10,9,5]

Hours Left ->

0 1 2 3 4 5 6 7 8 -> hours left