mid1-key

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

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

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

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

View Full Document
(c) An algorithm must be finite, that is, it must terminate at some point. Each operation in an algorithm must be unambiguous. (See the algorithm definition in the textbook if you missed this.)
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

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern