Computer Science 101 Survey of Computer Science Exam 3 - Fall 2008 Name: Pledged: 1. (35 points) Complete the following: a. If a multiplexor has 16 input lines, then it has output lines. One unit within the computer architecture where we proposed the use of a multiplexor was the unit. There the multiplexor was used to b. If a decoder has 16 input lines, then it has output lines. One unit within the computer architecture where we proposed the use of a decoder was the unit. There the decoder was used to c. In order to fetch the contents of a memory cell, the address of the cell must be placed in the register. If the memory unit can have a maximum of 16M cells, then this register would need to be bits wide. The memory register that holds the content of the cell once it has been fetched is the register. d. At the beginning of the fetch phase of the fetch-decode-execute cycle, the address for the instruction to be fetched would be found in the register which is located in the fetch phase, the instruction would be in the unit. Immediately after the register. 2 e. Using the assembly language for the hypothetical lab machine, assume that we have memory locations with labels X, Y, Z. Starting over for each part, give a statement or series of statements that would i) Add 1 to the value that is in the memory location with label X. ii) Replace the value stored at location X with twice its current value. iii) Put the address of the memory location with label X into PC. iv) Get a value from the user into R. v) Definitely put 010 into the CCR f. Circle the statement types whose fetch phase could possibly change the value R: SUBTRACT, JUMPLT, COMPARE, STORE, LOAD, INCREMENT, IN, OUT, CLEAR, JUMP g. Circle the statement types whose execute phase could possibly change the value in R: SUBTRACT, JUMPLT, COMPARE, STORE, LOAD, INCREMENT, IN, OUT, CLEAR, JUMP h. The following are the clauses of an SQL query statement: GROUP BY, ORDER BY, SELECT, HAVING, WHERE, FROM The clause is used to specify the tables used in the query. The clause is used to sort the results. The counting, etc. clause is used to combine result rows for purposes of 3 i. For each of the following relationships between presidential candidates and party primary elections, indicate whether it would most likely be considered 1:1, N:1(or 1:N), or N:M RanIn indicating candidate ran in the primary WasWinnerOf indicating candidate won the election WasFirstWin indicating the primary was first win for candidate PlaceInTopThree indicating candidate was one of top three finishers in the primary Assembly Language Table for use on following problems: Numeric Assembly Language Op Code Mnemonic Op Code 0000 0001 0010 0011 0100 0101 0110 0111 LOAD X STORE X CLEAR X ADD X INCREMENT X SUBTRACT X DECREMENT X COMPARE X 1000 1001 1010 1011 1100 1101 1110 1111 Mnemonic JUMP X JUMPGT X JUMPEQ JUMPLT JUMPNEQ X IN X OUT X HALT 2. (20 points) Using the assembly language for the hypothetical machine: a. Write a complete assembly language program, including pseudo-operations, for a program that allows the user to enter 2 numbers, say X, and Y, and then outputs the value of X – 2Y – 1 . 4 b. For this problem, you are to use the techniques covered in class to convert the following pseudocode program to an assembly language program. Pseudocode Set Large to 0 Get Num While Num > 0 do If Num>Large then Set Large to Num Get Num End-of-loop Print Large Stop 5 3. (10 points) Write a complete HTML document that would produce a page that looks like the page below, complete with title in title bar and links to the listed web sites. You can use the web addresses: http://amazon.com, http://weather.com, and http://google.com. 6 4. (15 points) Assume that the first few memory cells of our hypothetical lab machine have the following contents: Address (decimal) 0 1 2 3 4 5 6 7 Contents(binary) 0000000000000111 0100000000000111 0001000000000111 1110000000000111 1111000000000000 0000000000000010 0000000000000101 0000000000000011 Assume further that the machine is ready to begin the fetch-decode-execute cycle, that the PC holds 000000000000, and that the register R holds 0 (decimal). Please use instruction format for instructions and decimal for numerical values. Tell exactly what will be stored in each of the following locations at the end of the: First Fetch Phase First Execute Phase PC: PC: IR: IR: MAR: MAR: MDR: MDR: R: R: Memory location 7: Memory location 7: Second Fetch Phase Second Execute Phase PC: PC: IR: IR: MAR: MAR: MDR: MDR: R: R: Memory location 7: Memory location 7: Third Fetch Phase Third Execute Phase PC: PC: IR: IR: MAR: MAR: MDR: MDR: R: R: Memory location 7: Memory location 7: 7 5. (20 points) The following are the tables together with their columns from our class database: Students(StudentId,LastName,FirstName,ClassYear,City,State,Birthdate, AdvisorId,Term) Faculty(FacultyId, LastName, FirstName, Phone, Email) Interests(InterestId, InterestName, Category, URL) Majors(MajorId, MajorName, Department, ChairId) StudentInterest(StudentId, InterestId) StudentMajor(StudentId, MajorId) Give SQL query statements for each of the following a. Give an alphabetical list of the names of the students who are seniors from the state of Virginia. b. Give the names of the faculty members who are the advisors of students from the state of Virginia. 8 c. Give a list of the names of students who listed “The Dave Matthews Band” as one of their favorite music groups. d. Give a list of the categories of interests and the number of different interests for each category. The list should be in descending order of the counts. Among categories with the same count, the categories should be in alphabetical order. The list should only contain categories with at least 10 interests in the category.