Question: Write the C++ classes called ArithmeticProgression and GeometricProgression that are derived from the abstract class Progression, with two pure virtual functions, getNext() and sum(). Each
Write the C++ classes called ArithmeticProgression and GeometricProgression that are derived from the abstract class Progression, with two pure virtual functions, getNext() and sum(). 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, . . .
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
