-1) Print forever 0) Count(N) -> print 1, 2, 3, 4, ... N 1) Make a function that computes the factorial of n. fac(3) = 6 // 3*2*1 fac(5) = 120 // 5*4*3*2*1 2) Make a method that prints n spaces and then a '*'. stars(3) -> " *" stars(7) -> " *" 3) Make a method that computes A to the Bth power power(3,5) -> 243 power(2,3) -> 8 power(0,1) -> 0 power(0,0) -> anything you want 5) Make a method that computes the remainder of A divided by B remainder(17,3) -> 2 remainder(17,13) -> 4 remainder(3,33) -> 0 6) Make a function that computes integer the log base b of a. logg(8,2) -> 3 because 2^3 = 8 logg(81,3) -> 4 because 3^4 = 81 log(82,3) -> 4 because 3^4 < 82 and 3^5 > 82 9) Multiply mul(3,5) = 15 mul(7,3) = 21 10) Djikstra's GCD algorithm gcd(a, b) -> a if a==b gcd(a, b) -> gcd(a-b, a) if a > b 11) IsPalindrome isPalindrome("abba") = true isPalindrome("fred") = false isPalindrome("") = true and does not crash 12) PrintBackwards printBackwards("pretty") should print "yttep". It returns nothing. printBackwards("gene") should print "eneg". It returns nothing. 13) Make a method that returns a string backwards backwards("Hello") -> "olleH" backwards("") -> "" Hint: You can extract a substring with name.substr(start, length) Hint: You can get any given letter from a string with name.at(5) or name[5] Hint: The length of a string is name.length() --Array Stuff-- // RecursionArray.cpp : main project file. #include "stdafx.h" #include #include using namespace std; int main() { random_device rd; // non-deterministic generator mt19937 gen(rd()); // Seed the random number generator const int SIZE = (gen() % 10 + 5); cout << "There are " << SIZE << " items." << endl; int *data = new int[gen() % 10 + 5]; for(int i = 0; i < SIZE; i++) { // PICK JUST ONE OF THESE!!! // Random order for everything but binary search data[i] = (int)(gen() % 20); // Sorted order for binary search //data[i] = (int)(gen() % 20 + 20*i); } for(int i = 0; i < SIZE; i++) cout << "DATA[" << i << "]=" << data[i] << endl; system("pause"); } 14) Using the code above, print an array recusively printArray(data, SIZE) -> prints all the data 15) Using the code above, Does the array contain the target? contains(data, target, SIZE) -> TRUE if there is a 'target' in the first 10 items data 16) Using the code above,, Find the largest element findMax(data, SIZE) -> returns the biggest element among the first ten in data 17) Using the code above, binary search binsearch(data, SIZE, target) -> returns true if target is in data. data must be in sorted order. uses binary search