Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Comp200 – Elements of Computer Science Take-Home Final Rice University - Instructor: Dung Nguyen December 07, 2005 PRINT NAME: _________________ Instructions 1. This is an open-notes, open-book exam. 2. ALL USUAL HONOR CODE RULES APPLY. 3. You may take up to five hours from the time you open the exam to complete it. 4. You are free to use any materials that were given to you in the lectures. 5. You are free to use DrJava, DrScheme, EXCEL, and MS ACCESS and any on-line help materials that these software provide. 6. If necessary, you may draw any diagram by hand on the print out of the exam. 7. When you are done: Upload all the files of your work together to the “Final” assignment on the course WEBCT. Since multiple submissions are not allowed, submit the final version of your work only. Turn in the hard copy of the exam at DH 3098: be sure to sign the Honor Pledge. 6. The exam is due at 5 PM, Dec. 14, 2005. No late submission will be accepted. Please write and sign the Rice Honor Pledge here: 1a 1b 1c 2a /10 pts /10 pts /15 pts /10 pts 3a 3b 3c 3d /2 pts 7/13/2017 /2 pts /16 pts 2b /2 pts 3e /5 pts /5 pts 1 of 7 2c /2 pts 3f /5 pts 2d /3 pts 2e /3 pts 2f /10 pts Total /100 pts Comp200 – Elements of Computer Science Take-Home Final Rice University - Instructor: Dung Nguyen December 07, 2005 PRINT NAME: _________________ 1. (Total 35 pts) Logic circuit. The logic circuit shown below can be viewed as a logic function that takes 3 boolean inputs A, B and C and produces a boolean output F. In other words, F is viewed as a boolean function of A, B, and C. A D B F E C a/ (10 Pts) Use EXCEL to set up the truth table for the above circuit. 7/13/2017 2 of 7 Comp200 – Elements of Computer Science Take-Home Final Rice University - Instructor: Dung Nguyen December 07, 2005 PRINT NAME: _________________ b/ (10 Pts) Write the following Scheme boolean functions to model the above circuit. D as a function of A and B E as a function of B and C F as a function of A, B and C Be sure to write the contract, header and purpose for each of the above functions. 7/13/2017 3 of 7 Comp200 – Elements of Computer Science Take-Home Final Rice University - Instructor: Dung Nguyen December 07, 2005 PRINT NAME: _________________ c/ (15 Pts) Write a Java class called Multiplexer with appropriate boolean methods to model the above circuit, as specified in the below. NOTE: In Java, the notation for AND is &&: X AND Y is written as X && Y OR is ||: X OR Y is written as X || Y NOT is !: NOT X is written as !X (12 pts) class Multiplexer { /** * Represents the output at D as a function of the inputs at A and B. * @param a is the input at A * @param b is the input at B */ boolean D(boolean a, boolean b) { // STUDENT TO COMPLETE } /** * Represents the output at E as a function of the inputs at B and C. * @param b is the input at B * @param c is the input at C */ boolean E(boolean b, boolean c) { // STUDENT TO COMPLETE } /** * Represents the output at F as a function of the inputs at A, B and C. * Must make use D and E as defined in the above. * @param a is the input at A * @param b is the input at B * @param c is the input at C */ boolean F(boolean a, boolean b, boolean c) { // STUDENT TO COMPLETE } } (3 pts) Write the code that you would write in the Interactions pane of DrJava to test the method F for the following cases: A = true, B = true, C = true A = true, B = true, C = false A = false, B = true, C = true A = true, B = false, C = true 7/13/2017 4 of 7 Comp200 – Elements of Computer Science Take-Home Final Rice University - Instructor: Dung Nguyen December 07, 2005 PRINT NAME: _________________ 2. (Total 30 pts) Turing Machine Consider a Turing machine with an alphabet consisting of ‘X’, ‘Y’ and ‘b’ where b stands for the blank character, five states q0, q1, q2, q3, and q4 where q0 is the start state and q4 is the final (stop) state, and the following state transition diagram Current State q0 q0 q0 q1 q1 q2 q2 q3 q3 q4 Current Symbol b X Y X Y X Y X Y HALT Next State q4 q2 q1 q3 q0 q0 q3 q1 q2 a/ (10 pts) Draw an equivalent state transition diagram for the above. 7/13/2017 5 of 7 Next Symbol b X Y X Y X Y X Y Direction R R R R R R R R R Comp200 – Elements of Computer Science Take-Home Final Rice University - Instructor: Dung Nguyen December 07, 2005 PRINT NAME: _________________ When a Turing machine is a state q and there is no matching transition rule for the current input symbol, the Turing machine is said to “crash,” meaning it terminates computation unsuccessfully. For example, the above Turing machine, when it is in state q1 and sees a blank as the current input, has no matching transition rule and will crash in this case. Whenever a Turing machine ends up in a final (halt) state, we say that the Turing machine has successfully completed its computation. In each of the questions b/, c/, d/ and e/, below, you are given an sequence of symbols as input, assuming the Turing machine starts reading from the left most non-blank symbol. You are to determine whether or not the Turing machine halts in a final state or crashes in each case. You must give a short and concise explanation for your answer. For example, suppose the input is simply the symbol X. The Turing machine will change to state q2, write X on the tape and move right. Now it sees a blank, and since there is no transition rule for q2 when the current input is a blank, the Turing machine will crash. NOTE: You are not required to draw a snapshot of each of the steps in the computation. b/ (2 pts) Input is XY. c/ (2 pts) Input is XYY. d/ (3 pts) Input is XYYX. e/ (3 pts) Input is YYYYXX. 7/13/2017 6 of 7 Comp200 – Elements of Computer Science Take-Home Final Rice University - Instructor: Dung Nguyen December 07, 2005 PRINT NAME: _________________ f/ (10 Pts) Describe the form of input the Turing machine is able to read and terminate successfully in a halt state and the form of input that will cause the Turing machine to crash. Explain your answer 3. (Total 35 pts) Database The Registrar needs to keep track of the students and the courses they take. They also need to keep track of the professors and the courses they teach. There are cases where two or more professors co-teach the same course. Each student has a student ID that is unique, a first and last name and a gender. Each course has a unique course code (for example Comp200), a course name, and a number of credits. Each professor has a unique faculty ID, a first and last name and a phone number. a/ (2 Pts) What is the relationship between the students and the courses? Briefly explain your answer. b/ (2 Pts) What is the relationship between the professors and the courses? Briefly explain your answer. c/ (16 Pts) Design a relational database using MS ACCESS to model the students, the courses, the professors and the relationships between them. For the student’s gender, use the Yes/No data type where Yes means ‘female’ and No means ‘male’. For the professor’s phone number, set the appropriate input mask to enter and store the number in the form (area code) 3 digits – 4 digits. Be sure to use the Lookup Wizard to connect the foreign key to the main key in all one-to-many relationships. Be sure to enforce referential integrity in all one-to-many relationships. Display all the tables in the Relationships window. The Relationships diagram must clearly show all the relationships between all relevant tables. d/ (5 Pts) Enter sample data in all tables to illustrate the relationships between the related tables. There should be at least (fictitious) data for four students, three courses and two professors. e/ (5 Pts) Given the above database design, describe an algorithm to list all the students that have ever taken a course with a given professor. For example, how do you find all the students that have taken a course with Professor John Smith? f/ (5 Pts) Now the Registrar wants to keep track of the letter grade for each of the courses each student takes. Which table do you have to modify to store this information? Describe briefly what you need to do. Do not modify any of your tables in the above design. IMPORTANT: Be sure to close MS ACCESS before uploading your database to WEBCT. Wait until you finish all the problems before uploading their solutions to WEBCT. You can only upload your solution files once. So be sure to upload the final version of all the files together. 7/13/2017 7 of 7