Question: (True/False) You can construct a circuit for any truth table using only NOT, OR, and AND gates Answer: True ------------------------ Question: This truth table a | b | output 0 | 0 | 0 0 | 1 | 0 1 | 0 | 1 1 | 1 | 1 is represented by the expression A) (a AND NOT b) OR (NOT a and NOT b) B) (a AND NOT b) C) (a AND NOT b) OR (a AND b) D) (a OR NOT b) AND (a OR b) Answer: C ------------------------ Question: Determine the expression for the following truth table obtained using the sum of products algorithm (give either a boolean expression or the circuit diagram) a | b | output 0 | 0 | 1 0 | 1 | 0 1 | 0 | 0 1 | 1 | 1 Answer: (NOT a AND NOT b) OR (a AND b) ------------------------ Question: If there are five inputs, how many rows will there be in the truth table? Answer: 2^5 = 32 ------------------------ Question: What are the inputs and outputs for a 1-bit full adder circuit? (adding numbers a and b to produce s) Answer: Inputs: carry from add of i-1th digits, a_i and b_i Outputs: carry from add of ith digits and s_i ------------------------ ======================================= ======================================= Question: Consider the following predicate (boolean) function: def blockedWithinOneMove(self): if (not self.front_is_clear()): return true else: self.move() if (not self.front_is_clear()): return true else: return false What is wrong with this predicate? Answer: It could leave the robot one block away from its original position ------------------------ Question: Write a function that turns the robot to the North. Answer: def faceNorth(self): while (not self.facing_north()): self.turnLeft() ------------------------ Question: Write a function that will cause Karel to move backwards Answer: def walkBackwards(self): self.turnLeft() self.turnLeft() self.move() self.turnLeft() self.turnLeft() ------------------------ Question: If the following code takes 10 seconds to execute when there are n beepers on the corner of 2,2, how many seconds does it take to execute when there are 3n beepers on the corner? max = UsedRobot(2,2,East,0) while (max.on_beeper()): max.pick_beeper() max.turnOff() Answer: 30 seconds ------------------------ Question: Assume Karel is standing on a pile of beepers. Write a function that will leave karel facing north if there are an even number of beepers in the pile, and facing south otherwise. Answer: def evenOdd(self): count = 0 while (self.on_beeper()): self.pick_beeper() count = count + 1 while (not self.facing_north()): self.turnLeft() if ((i % 2) != 0): self.turn_around() for (x in range(count)): self.put_beeper() ------------------------ ======================================= ======================================= Question: (True/False) A binary number always requires more digits than the equivalent decimal number. Answer: False (1 in binary and 1 in decimal take 1 digit) ------------------------ Question: Convert -27 (base 10) to binary two's complement in 8 bits A) 11101011 B) 11110111 C) 10101010 D) 11100101 Answer: D ------------------------ Question: How many bytes are required to store "This is fun" in ASCII code? Answer: 11 ------------------------ Question: If we have 8 bits to store a two's complement number, what is the smallest negative number (largest absolute value) we can store? Answer: 2^7 = -128 ------------------------ Question: (True/False) The addition of the two's complement numbers 01111101 and 10011010 causes overflow. Answer: False ------------------------ ======================================= ======================================= Question: The Von Neumann model includes all of these characteristics except: A) 4 subsystems B) sequential execution of instructions C) addresses are always 8 bits long D) programs are stored in memory along with data Answer: C ------------------------ Question: How many rows are in the truth table for a circuit with 4 possible inputs? Answer: 16 ------------------------ Question: (True/False) In 4 bits, the most negative number that can be represented in twos complement form is -16. Answer: False ------------------------ Question: Binary numbers rather than decimal are used in computers because (choose all that apply) A) They are easy for people to use B) You can store larger numbers in a smaller amount of space C) They are more reliable in the presence of electrical fluctuations D) It doesn't take as much ink on a page to write a digit Answer: C only ------------------------ Question: Which of the following expressions is equivalent to NOT(A OR B) A) (NOT A) AND (NOT B) B) (NOT A) OR (NOT B) C) NOT (A AND B) D) (NOT A) AND (NOT B) AND A AND B Answer: A ------------------------ ======================================= ======================================= Question: What does it mean to say that a step in an algorithm is effectively computable? Answer: It means that the computing agent is capable of carrying out the step ------------------------ Question: Base 10 uses 0-9 as digits. For base 16, which digits are added? Answer: A,B,C,D,E,F ------------------------ Question: Computers use volatile and non-volatile storage Give one example of each type Answer: Primary memory or RAM is volatile storage and a hard disk or CD are examples of non-volatile storage. ------------------------ Question: From The Matrix: what is the name of the company where Mr Anderson works? A) Cyberdyne Systems B) Metacortex C) Weyland Yutani Corporation D) Tyrell Corporation Answer: B ------------------------ Question: The memory cell at address 32 contains 00010001. Is this a sign-magnitude format integer, an ASCII code for a character or a two's complement integer? Answer: Without more information, there is no way to know. We will only know when we know the context in which the memory contents are used. ------------------------ ======================================= =======================================