Question 1 (25 points) --------------------- 1.a. Determine the value of each of the indicated variables after the following code executes. Assume that each integer occupies 4 bytes and that m is stored in memory starting at byte 0x3fffd00 (10 points) int m = 44; int *p = &m; int &r = m; int n = (*p)++; int *q = p -1; r = *(--p) + 1; ++ *q; (i) m (ii) n (iii) &m (iv) *p (v) r (vi) *q 1.b. What is the problem with the following declaration ? (5 points) int **p = &&n; 1.c. Explain the difference between the following two declarations ? (5 points) double *f(); double (*f)(); 1.d. What is the problem with the following code snippet ? (5 points) float x = 3.14159; float *p = &x; short d = 44; short * q = &d; p = q ; Question 2 (25 points) ----------- Implement the Bisection method for solving equations. Use the following function. double root(double (*pf)(int k), int a, int b, int n) Here pf point to a function f that defines the equation f(x) = 0 that is to be solved, a and b bracket the unknown root (i.e., a <= x <= b), and n is the number of iterations to use. For example, if f(x) = x^2 - 2, then root(f,1,2,100) would return 1.414213562373095 = sqrt(2), thereby solving the equation x^2 = 2. The Bisection Method works by repeatedly bisecting the interval and replacing it with the half that contains the root. It checks the sign of the product f(a)f(b) to determine whether the root is in the interval [a,b]. Your code should run at the function f(x) = x^3 - 2. The input to your source code should be the number of iterations, and the values of a and b. sample input ----------- 100 1 2 // number of iterations, a, b Sample output ------------ 1.257 // the root Question 3 (50 points) ---------------------- Write a program which creates a dictionary of words from a file. Your program should take as an input a file name. Then you should read the file and create a dictionary of words in the file. For example, if the input file (say foo.txt) has the following line "The fox jumped out of the basket" The dictionary for this file should look like the 2 fox 1 jumped 1 out 1 of 1 basket 1 Note that "The" and "the" are treated as the same word. Do not use maps (we will redo the assignment with maps later). You can use structs/classes. Hint : Here is a piece of code which reads lines from a file #include #include int main() { fstream iofile("input.txt",ios::in); if(!iofile.fail()) { while(!iofile.eof()) { char data[MAX]; iofile.getline(data,MAX); } } iofile.close(); } Sample input ------------ foo.txt // filename Sample output ------------- the 2 // the words followed by the number of times a word occurs fox 1 jumped 1 out 1 of 1 basket 1