recursiveFunction(5) prints "531-1" recursiveFunction(10) prints "1097531-1" recursiveFunction(0) prints "0"
531-1 1097531-1 0
This is for C in Linux: Problem 1: Given the following recursive function: void recursiveFunction( int...
Write as a shell script Write as a shell script # include <stdio.h> int main (void) {int area_code, prefix, number; printf("Enter phone number [(999) 999-9999]:"); scanf("(%d)%d-%d", &area_code, & prefix, & number); printf("You entered %d-%d-%d \n", area_code, prefix, number); return 0;}
QUESTION 26 Given the following function: int secret(int num, int m) inti, prod=1; if (m=0) return 1: - for (i=0; i<m; i++) { prod = prod * num; } return prod; What is the output for this function call? cout << secret(10,6);
(a) Consider the following C++ function: 1 int g(int n) { 2 if (n == 0) return 0; 3 return (n-1 + g(n-1)); 4} (b) Consider the following C++ function: 1 bool Function (const vector <int >& a) { 2 for (int i = 0; i < a. size ()-1; i ++) { 3 for (int j = i +1; j < a. size (); j ++) { 4 if (a[i] == a[j]) return false; 5 6 } 7 return...
Can someone hand trace this basic recursive function? Please hand-trace and show me all the steps. I do not understand how this works. Expected output is: The output is: Message 3 Message 2 Message 1 Message 0 Message 0 is returning. Message 1 is returning. Message 2 is returning. Message 3 is returning. int main() message(3); return e; void message (int times) cout <"Message<< times<.n" if (times >e) message(times 1); else cout << "Message "<< times<< "is returning. n"
Problem 1. Select the running time of each function. void print_array (int* A, int n) for (int í 0; i < n; ++i) cout << A[i] << endl; void print_array pairs (int* A, int n) for (inti 0; i < n; ++i) for (int j 0; j < n; ++j) cout << Ai] ALj]< endl; void print_array_start(int* A, int n) for (int i 0; i < 100 ; ++i) cout << A[i] << endl; void print_array_alt (int* A, int n)...
1. 2. Find the tight bound on the run time for problem 1 and 2 void phone (int n) if (n <147) time +54 else { for (int 0; i< n/2; i++ time++ phone (n/3); for int i = 0; i <13*n; it+) time++ phone (2*n) 3) } void belt (int n) if (n 200) time +=700 else belt (7*n)/10) for (int i-0; i<n; i++) time++ belt (n/5) 0 i <130n; i+-10) for (int i time++ }
3) Consider the following recursive method, what will be the output for the following method calls? Explain. (25 pts.) public static void sample (int number) if (number < 0) { System.out.println( superwriteVertical (-number); System.out.println(number); superwriteVertical (number/ 10); else if (number 10) else ( System.out.print1n(number % 18); sample(-100); sample(50); sample(1024);
1. What is the output of the following program? include <stdio.h> int wilma (int x) if (x<5) x = 7; return (x) int main (void) int x-1 x=wilma (x) ; printf ("%d", x); return (0) b)3 c) 4 d) 7 a) 1 e) none of these
22. (6 points) Determine the output for the following coe # include < stdio.h > int main(void) ( int z 1, total -0, y printf(d , x) ) //end-for printf("The total %d\n", total) ) //end-main
6. Using big-oh notation, give the runtime for each of the following recursive functions. You do not need to justify your answers: a) Int nonesense (int n) if (n <0) return 1; return nonsense (n-2) 1; b) int no nonesense (int n) if (n <0) return 1; return no_nonsense (n-1)+ no nonsense (n-1)