CS 361, Introduction to Data Structures Final Exam Fall 2012 Open book, open notes, but you are not to communicate with anyone else in any manner concerning this exam during the exam period. The ODU Honor code is in effect for the duration. You are to solve no more than 3 of the following problems in C++, using the STL library; each code should run stand-alone as a simulation. You can develop the code in any environment but they should compile using Codeblocks, DEV or g++. Submit your solutions as a single zipped file via the web-submit utility found at www.cs.odu.edu/~cs361m. 1. Imagine that there are processes that are being generated at random intervals, each process has an id (0001 to 9999) and in addition each process has a complexity score that is directly proportional to the product of its required memory and its expected run time. We can treat the complexity score (c >= 0) as a random value with a mean of 5 and a standard deviation of 1. As the processes are generated they are placed into a queue of length q (user input). Processes are removed from the front of the queue after they have been in the front for c time steps. IF a process is generated and the queue if full then the overload is placed in a separate priority queue with the lowest c score given the highest priority. When room is made in the process queue, it is refilled from the priority queue. Generate a simulation of this process handler. Time 1 2 3 4 Queue <> <P1, P2> <P1,P2,P3> <P2,P3> New Processes P-id(c) P1(3) P2(1) P3(4) None P5(1) Priority Queue <> <> <> 22 23 24 etc <P44(2), P45, …P54> <P44(2), P45,…P54> <P44(2) P45, P54> <P45, P54, …P54, P56> P55(3), P56(1) P57(2) None None <> <P56, P55> <P56, P57, P55> <P57, P55> 2. Imagine a chess board (8x8) with one knight on it. The knight is placed at location row 0 and column 1, (standard position), implement an algorithm that will allow the knight to move around the board randomly until ALL locations have been visited. 3. This is an experimental question, please implement the following code fragment in a fully functional C++ code. Given ints j, n, and T: where n is user input, the functions b is return type bool, and both p( ) and q( ) each return a time cost . The value T stores the cumulative sum of those costs. i. For(j=0; j<n; j++) ii. {If b(j) {q(j);} iii. Else { 1. If(b(j+1){q(j-1);} 2. Else {p(j+3);} 3. } iv. } Where b(i) takes i+2 seconds and (on average) the function b( ) returns true 50% of the time q(i) takes i seconds p(i) takes i+1 seconds Create a graph showing best, average, and worst case T scores for your code in number 5 above for n = powers of 2 from 21 to 216. If there are any results you cannot provide be specific as to the reason. 4. In DNA there are four base nucleotides; A, T, C and G. The genetic code consists of three-letter 'words' called codons formed from a sequence of three nucleotides (e.g. ACT, CAG, TTT). Since there are 4 bases and they are in 3-letter combinations, there are 64 possible codons (43 combinations). These encode the twenty standard amino acids giving most of them more than one possible codon. There are also three 'stop' or 'nonsense' codons signifying the end of the coding region; these are the TAA, TGA and TAG codons. You are to create a class codon which contains three chars (A, T, C, and G). Then accept from the keyboard two inputs. The first will determine the length of the strand (not including a stop codon). The second will be a three chars (CGC etc.) Your code will create a VECTOR using the STL template of codons with random composition. Then it will search for the target string, if it is found it will display not only the complete strand but will give the index(indices) of the targets location. If it is NOT found just display the strand. 5. Imagine there are spheres in a 3d space contained in the 1st octant (all coordinates x, y, and z are positive). Accept from the keyboard two sets of data that represent the center and radius of spheres. You are to compute if they intersect or not, display their data and the location of the two points (A and B) showing the extreme intersection points. A 2-D version is show in the graphic below.