mid1-key - (d • Tying shoelaces • Riding a bicycle(This...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSci 1001 — Spring 2010 Midterm 1 KEY Who graded what: Problem 1: Faraz Mohammad-Mirzaei Problem 2: Faraz Mohammad-Mirzaei Problem 3: Tyler Smith Problem 4: Phil Barry Problem 5: Jonathon Lawson Problem 6: Phil Barry Problem (1) A B A OR B A XOR B NOT (A XOR B) (A OR B) NOT(A XOR B) F F F F T T F T T T F F T F T T F F T T T F T T Problem (2) (a) False —- T XOR T (b) True — NOT(F OR T) T (c) False — T (F AND T) Problem (3) (a) - 42 (by bits: - 128 + 64 + 16 + 4 +2 = - 42) (b) 00101001 (c) 10000101 + 00101111 ---------- 10110100 Problem (4) (a) Act utilitarianism. (See the ethics notes linked to the class schedule page if you missed this). (b) False cause fallacy. (See the logical arguments notes linked to the class web page if you missed this). 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
(c) An algorithm must be fnite, that is, it must terminate at some point. Each operation in an algorithm must be unambiguous. (See the algorithm defnition in the textbook iF you missed this.)
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (d) • Tying shoelaces. • Riding a bicycle. (This is similar to the last problem in HW 1; see the HW 1 key iF you missed this.) Problem (5) The algorithm prints ’check’ since at its end sum is 16. Here are the values oF i and sum at the end oF the execution oF line 8: i sum------2 1 3 4-1 5-2 6 3 7 9 8 8 9 16 Note that in the loop you add the value oF i to sum when a[i] is 1, but you subtract 1 From sum when a[i] is 0. Problem (6) Algorithm: 1 Get a regular, shu±ed, deck oF 52 cards in a Face down pile. 2 Set count ← 3 Set numAces ← 3 While numAces < 4 4 Turn over the top card in the pile oF Face down cards 5 IF the card is an ace then 6 Set numAces ← numAces +1 7 Set count ← count +1 8 Output count , ‘ cards turned over’ 9 Stop 2...
View Full Document

This note was uploaded on 10/28/2010 for the course CSCI 1001 taught by Professor Staff during the Spring '08 term at Minnesota.

Page1 / 2

mid1-key - (d • Tying shoelaces • Riding a bicycle(This...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online