Question: Data Structures in C++ Implement all of the functions in this assignment recursively. If I see just one loop or unauthorized standard algorithm, youll get

Data Structures in C++

Implement all of the functions in this assignment recursively. If I see just one loop or unauthorized standard algorithm, youll get no credit.

Implement the function that computes the sum of all even numbers less than or equal to n:

int sum_evens(unsigned int n); 

Recursively implement multiplication of two unsigned ints, a and b, using only addition. If you use *, you get no credit. Assume that a >= 0. (Hint: think about multiplication as repeated addition.)

int multiply(unsigned int a, unsigned int b); 

(5) Implement a function to find the smallest element in an array of int:

int smallest(int* arr, int length); 

(6) Implement a function that tests whether a string is a palindrome (reads the same backwards and forwards).

bool is_palindrome(string s); 

(7) Implement a function that determines whether a given int is an element of an array of int:

bool is_element_of(int i, int* array, int length); 

(8) Using your function in (7), implement a function which determines whether one array is a subset of another (that is, whether every element in array a is also an element of array b):

bool is_subset(int* a, int length_a, int* b, int length_b); 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!