Question: QUESTION 33 Which of the following algorithm complexities has the fastest rate of increase (i.e., represents the least efficient algorithm)? A. O(N2) B. O(log2 N)
QUESTION 33 Which of the following algorithm complexities has the fastest rate of increase (i.e., represents the least efficient algorithm)? A. O(N2) B. O(log2 N) C. O(2N) D. O(N) 2 points
QUESTION 34 Consider the following C++ program: #include using namespace std; void f1(int); void f2(int); void f3(int); int main() { f1(10); return 0; } void f1(int n) { f2(n + 5); } void f2(int n) { f3(n - 2); } void f3(int n) { cout << n << endl; // LINE 1 } Just before the program statement marked with the comment "LINE 1" is executed, how many stack frames will be on the program call stack? (Your response should just be a number without any additional text.)
QUESTION 35 In any given Unix directory, the relative pathname of the current directory is __________. (Your response should just be the pathname without any additional text.)
QUESTION 36 Consider the following recursive function: int f(int n) { if (n == 1) return 1; else return n * f(n - 1); } Assume that the function is called using the following statement: int result = f(6); What will be the value of the variable result after the function is called? If the function would not return a final value, briefly explain why.
QUESTION 37 How many lines of output will this C++ function print if the value of n is 99? void print_array(int array[], int n) { int i; for (i = 0; i < n; i++) { cout << array[i]; if (i % 12 == 0)) cout << endl; else cout << ' '; } }
QUESTION 38 Write a C++ statement to define a two-dimensional array of integers named sales with ten rows and twenty columns.
QUESTION 39 Consider the following recursive function: int f(int n) { if (n == 1) return 1; else return n + f(n); } Assume that the function is called using the following statement: int result = f(10); If run on our Unix system, this function call will result in a segmentation fault. Give a brief explanation (one or two sentences should be sufficient) of why that will happen.
QUESTION 40 Rewrite the contents of the following array once the array has been partitioned by a single call to the quicksort partition function covered in class and available on the handout. (Hint: the pivot value will be 36.) 80 73 25 36 18 60 29 54 .
QUESTION 41 Write a function definition for the function whose prototype is shown below. This function has a C string as its single parameter. It should return the number of alphabetic letters in the string. The function isalpha() can be used to determine whether or not a character of the string is a letter. int count_letters(const char* s).
QUESTION 42 Write a full C++ program to read a series of integer numbers from standard input and print them out in reverse order, one per line. You may assume that there will be a minimum of 2 numbers to read and a maximum of 200.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
