Homework #1

$24.99 $18.99

Type solutions to the homework problems listed below using preferably LYX/LATEX word processors, see the class webpage for more information about their installation and tutorials. (10 points) Write the C++ classes called ArithmeticProgression and GeometricProgression that are derived from the abstract class Progression, with two pure virtual functions, getNext() and sum(), see the course textbook…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:
Tags:

Description

5/5 – (2 votes)

Type solutions to the homework problems listed below using preferably LYX/LATEX word processors, see the class webpage for more information about their installation and tutorials.

  1. (10 points) Write the C++ classes called ArithmeticProgression and GeometricProgression that are derived from the abstract class Progression, with two pure virtual functions, getNext() and sum(), see the course textbook p. 87–90 for more details. Each subclass should implement these functions in order to generate elements of the sequences and their sums. Test your program for the different values of d, r and the number of elements n in each progression.

What is the classification of those functions: getNext() and sum() in terms of the Big-O notation? Recall the definitions of the arithmetic and geometric progressions.

Definition: An arithmetic progression with the initial term a and the common real difference d is a sequence of the form

a, a + d, a + 2d, . . . , a + nd, . . .

Definition: A geometric progression with the initial term a and the common real ratio r is a sequence of the form

a, ar, ar2, . . . , arn, . . .

Algorithm Ex4(A):

Input: An array A storing n ≥ 1 integers.

Output: The sum of the partial sums in A.

t ← 0

s ← 0

for i ← 1 to n − 1 do

  • s + A[i] tt + s

end for

return t

7

Homework #1
$24.99 $18.99