Question

12. 10 points) Use pseudocode to write out algorithms for the following problems. (a) Assume n is any integer with n 2 7. Wri
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Psuedocode for SumOfCertainIntegers()

void SumOfCertainIntegers(int n)
{
int k;
int sum=0,sum1=0;
for(k=7;k<=n;k++)
{
sum+=6*k;
sum+=4;
sum=pow(sum,3);
sum1+=sum;
sum=0;
}
printf("%d",sum1);
}

Psuedocode for ProductOfCertainIntegers()

void ProductOfCertainIntegers(int m)
{
int i=5;
int pdt=0,pdt1=1;
while(i<=m)
{
pdt+=i*i*i*i*i;
pdt+=4;
pdt1*=pdt;
pdt=0;
i++;
}
printf("%d",pdt1);
}

Add a comment
Know the answer?
Add Answer to:
12. 10 points) Use pseudocode to write out algorithms for the following problems. (a) Assume n is any integer with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Analysis of Algorithms Fall 2013 Do any (4) out of the following (5) problems 1. Assume n-3t is a...

    Analysis of Algorithms Fall 2013 Do any (4) out of the following (5) problems 1. Assume n-3t is a power of 3 fork20. Solve accurately the following recursion. If you cannot find the exact solution, use the big-O notation. Tu) T(n)Tin/3)+2 2. Suppose that you have 2 differeut algorithms to solve a giveu probleen Algorithm A has worst-case time complexity e(n2) and Algorithm B has worst-case time complexity e(nlog n). Which of the following statements are true and which are...

  • a. Write a pseudocode for computing for any positive integer n Besides assignment and comparison, your...

    a. Write a pseudocode for computing for any positive integer n Besides assignment and comparison, your algorithm may only use the four basic arithmetical operations. What is the time efficiency of your algorithm for the worst and best cases? Justify your answer. (The basic operation must be identified explicitly). Give one instance for the worst case and one instance for the best case respectively if there is any difference between the worst case and best case. Otherwise please indicate that...

  • Part I Short Answer (50 points) 1. Write a pseudocode declaration for a String array initialized...

    Part I Short Answer (50 points) 1. Write a pseudocode declaration for a String array initialized with the following strings: “Einstein”, “Newton”, “Copernicus”, and “Kepler”. 2. Assume names in an Integer array with 20 elements. Write a pseudocode algorithm a For Loop that displays each element of the array. 3. Assume the arrays numberArray1 and numberArray2 each have 100 elements. Write a pseudocode algorithm that copies the values in numberArray1 to numberArray2 . 4. Write a pseudocode algorithm for a...

  • ALGORITHM RecS(n) // Input: A nonnegative integer n ifn=0 return 0 else return RecS(n+ n n...

    ALGORITHM RecS(n) // Input: A nonnegative integer n ifn=0 return 0 else return RecS(n+ n n n Determine what this algorithm computes. You must justify your answer. made by this algorithm and solve it. You must justify your answer. same thing using for/while loop(s) developed in (3). You must justify your answer. 1) 2) Set up the initial condition and recurrence relation for the number of multiplications 3) Write the pseudocode for the non-recursive version of this algorithm, i.e., compute...

  • Spring 2020 CSCI 2450: HW5 (Programming Assignment (10 points) Answer any ONE of the following problems....

    Spring 2020 CSCI 2450: HW5 (Programming Assignment (10 points) Answer any ONE of the following problems. If you answer both of them, you will get bonus points. Use any instructions and Irvine procedures we covered till now. These problems might require instructions from chapter 07. Problem 1: Greatest Common Divisor ( GCD) Greatest Common Divisor (GCD): The greatest common divisor (GCD) of two integers is the largest integer that will evenly divide both integers. The GCD algorithm involves integer division...

  • URGENT Question 3 25 pts ArrayMystery: Input: n: a positive integer Pseudocode: Let output be an...

    URGENT Question 3 25 pts ArrayMystery: Input: n: a positive integer Pseudocode: Let output be an empty array For i = 1 to n j = 1 While ij <= n Addj to the end of output j - j + 1 Return output Answer the following questions about the ArrayMystery algorithm above. a) How many times will the inner while loop iterate? You should express your answer in terms of i and n, using Big-Oh notation. Briefly justify your...

  • Title Algorithms Functional Requirements and Marks using c++ Write a pseudo-code algorithm for the following problems:...

    Title Algorithms Functional Requirements and Marks using c++ Write a pseudo-code algorithm for the following problems: Detect if three angles can make a triangle.    (1) Hint: In a triangle, the sum of all angles is 180. Switch the value of two numbers     (1) If a=2 and b=5, we want to have a=5 and b=2 at the end. Remember that a=b will result in the old value to of a to get lost. Receive a set of numbers and find...

  • WHILE LOOPS (13 points) Write a MATLAB program to find the smallest integer N such that:...

    WHILE LOOPS (13 points) Write a MATLAB program to find the smallest integer N such that: i> limit For example, if the limit is 5, the smallest N would be 3 since 1 + 2 + 3 = 6, and 6 > 5. If the limit is 15, the smallest N is 6 because 1+ 2+ 3+ 4+ 5+ 6 = 21. Note that N is not 5 in this case because 1+ 2+ 3+ 4+ 5 = 15, and...

  • pleas answer asap 3. (20 points) Algorithm Analysis and Recurrence There is a mystery function called Mystery(n) and the pseudocode of the algorithm own as below. Assume that n 3* for some positiv...

    pleas answer asap 3. (20 points) Algorithm Analysis and Recurrence There is a mystery function called Mystery(n) and the pseudocode of the algorithm own as below. Assume that n 3* for some positive integer k21. Mystery (n) if n<4 3 for i1 to 9 5 for i-1 to n 2 return 1 Mystery (n/3) Print "hello" 6 (1) (5 points) Please analyze the worst-case asymptotic execution time of this algorithm. Express the execution time as a function of the input...

  • Q4) [5 points] Consider the following two algorithms: ALGORITHM 1 Bin Rec(n) //Input: A positive decimal...

    Q4) [5 points] Consider the following two algorithms: ALGORITHM 1 Bin Rec(n) //Input: A positive decimal integer n llOutput: The number of binary digits in "'s binary representation if n1 return 1 else return BinRec(ln/2)) +1 ALGORITHM 2 Binary(n) tive decimal integer nt io 's binary representation //Output: The number of binary digits in i's binary representation count ←1 while n >1 do count ← count + 1 return count a. Analyze the two algorithms and find the efficiency for...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT