Sale!

EECE 7205 Homework 1 solved

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (9 votes)

Problem 1 (20 Points) Write a C++ program to implement and test two functions: SwapP and SwapR. SwapP swaps the values of two integer variables using pass‐by‐pointer. SwapR swaps the values of two integer variables using pass‐by‐reference. Problem 2 (30 Points) Write a C++ program to test the following two functions. Call the functions with values for n between 1 and 10.   int F1(int n) { if (n == 0) return 1; return F1(n ‐ 1) + F1(n ‐ 1); } int F2(int n) { if (n == 0) return 1; if (n % 2 == 0) {     int result = F2(n / 2);     return result * result; } else     return 2 * F2(n ‐ 1); } Submit your test program and in your report answer the following questions: a. What does each function do? b. Which function is faster (hint: test them with n = 30)?   c. Explain why one function is faster than the other. EECE7205 ‐ Homework 1 3 / 3 Problem 3 (50 Points) Write a C++ program that starts by asking a teacher for the size of his/her class (the number of students). Then the program asks the teacher to enter for each student his/her name along with his/her grade in an exam. Only enter students’ last names as one word. All grades are integers that have to be in the range from 0 to 100 (inclusive). Store the names in an array of strings and the grades in another array of integers. Use dynamic memory to create both arrays.   Define a function that implements the insertion sort algorithm (a modified version of the algorithm presented in class). This function sorts the students’ info in a descending order of the students’ grades in the exam.   After calling the sorting function, your program will display the sorted students’ info (i.e., their names along with their grades sorted in descending order of the grades).