CS 131 Spring 2015, Midterm 2 Study Questions
Please post solutions to Piazza max 1 proof per customer
Question 1. Prove that 1(1!) + 2(2!) + . . . n(n!) = (n + 1)! 1. For practice, prove it two different ways: by
standard induction, and by applying the w
CS 131: Combinatoric Structures
Fall 2015
Homework 1
Instructor: Lorenzo Orecchia
Due: Tuesday, September 15 at 12pm noon
Reading Assignment:
Read HTPI sections 1.3 (Variables and Sets), 1.4 (Operations on Sets). We will only sketch some of
this material
CS 131: Combinatoric Structures
Fall 2015
Homework 8
Instructor: Lorenzo Orecchia
Due: Wednesday, November 18 at 11am
Reading Assignment:
MIT Notes 11.111.7. Try to go through 11.7 and solve each example on your own before reading the
solution.
Assigned
Computer Systems
CAS CS210  Fall 2016
https:/piazza.com/bu/fall2016/cs210/home
https:/piazza.com/bu/fall2016/cs210
http:/learn.bu.edu
Lectures: Tuesday and Thursday 2:00pm3:30pm Kenmore Classroom Building (KCB) 101
Discussions: Monday 89AM, 910AM, 10
# Problem 11
import random
def twoHeads():
"simulates the flipping of a coin 10^9 times and keeps track of
how many flips it takes to have two heads in a row
"
count = [0] * 51
head_count = 0
array_count = 0
for i in range(10*9):
flip = random.randint(0,1
Problem 4
rdi = h
esi = len
movslq %esi, %rsi /rsi = len
leaq 1(%rdi,%rsi), %rax /t(rax) = h +len1
cmpq %rax, %rdi /if h < t jump to .L3
L3:
movzbl (%rdi), %edx /moves one byte from rdi into edx, so edx = *h
xorb (%rax), 0l /dl = *h xor *t
movb 0l, (%rd
The LW instruction loads a 32bit value from memory and signextends this to 64 bits before storing
it in register rd for RV64I. The LWU instruction, on the other hand, zeroextends the 32bit value
from memory for RV64I. LH and LHU are defined analogousl
To analyze validity of an argument: construct truth tables for all the values of P, Q, R.
Check whether when all the premises are true conclusion is also true (valid argument).
A proposition is a declarative sentence that is either true or false. conju
Problem 1:
like cache, but no block offset
1024 = 2^10 = vpo/ppo
09 vpo
1015vpn
bit 10 and bit 11>tlb index
bit 1215 is tlb tag(left over from after indexes)
physical page number after vpo
Part 2:
0010 11 11 0000 1001 (copy plus 1 for physical addre
Practice midterm
1. little endian:
memory:
0x12345678
mem adder  value

100  78
101  56
102  34
103  12
big endianreversed.
unsigned int ux =. >making x signed
lines under it > doing logical expressions
signed>arithmetic right shift
ux >0x7ff
Uses bits in memory as lookup to find where cache is
tag bits: depend on memory address and set index and block offset.
Use given address to index into the cache and find data
Cache separated into sets, each row is a set. Lowercase s is how many sets>2^s
CS 131: Combinatoric Structures
Fall 2015
Homework 1
Instructor: Lorenzo Orecchia
Due: Tuesday, September 22 at 12pm noon
Reading Assignment:
Review HTPI sections 2.2,which was covered in our Tuesday lecture. In particular, make sure you are
aware of the
CS 131: Combinatoric Structures
Fall 2015
Homework 7
Instructor: Lorenzo Orecchia
Assigned Exercises:
1. (a) How many different n bits long binary strings in total ?
(b) How many different n bits long binary strings contain exactly 3 zeroes ?
(c) Define A
CS 131 Spring 2015, Assignment 9
Problems due by 5PM, Friday May 1
Question 1. Give a combinatorial proof (see Section 11.9) that 2n =
n
0
+
n
1
+
n
2
+ . +
n
n
.
(a) First, give a combinatorial argument that the total number of subsets of set A = cfw_x1
CS 131 Spring 2015, Midterm 1 Study Questions
Students are invited to discuss and post solutions to these problems on Piazza, but please wait until after the HW3
deadline, i.e., after Tuesday 5PM, so students can focus on that rst. One solution per studen
CS 131 Spring 2015, Assignment 7
Problems due by 5PM, Friday, April 10
Question 1. Another basic sorting algorithm is Insertion Sort, which can be described recursively as follows. As
with Mergesort, the input is a list of n numbers, and the output is the
CS 131 Spring 2015, Assignment 6
Problems due by 5PM, Friday March 27
Question 1. Number theory terms and algorithms.
(a) Prove that a linear combination of linear combinations of integers a0 , a1 , . . . , an is a linear combination of
a0 , a1 , . . . ,
CS 131 Spring 2015, Assignment 8
Problems due by 5PM, Friday April 24
For all of the counting problems below, you must justify your work, such as we did in class for the counting
passwords problem.
Question 1. Next week, Im going to get really fit. On day
CS 131 Spring 2015, Assignment 1
Problems due in the dropbox by 5PM, Friday January 30. Hard deadline!
All of our homeworks will require short proofs. In writing up proofs, try to follow the style in our textbooks and
make sure your reasoning ows logical
CS 131: Combinatoric Structures
Fall 2015
Homework 11
Instructor: Lorenzo Orecchia
Due: Wednesday, December 9 at 11am
Reading Assignment:
MIT Notes Chapter 12  all sections except 12.4.4 and 12.5.3
Alternative Source: notes by Michel Goemans on generat
CS 131: Combinatoric Structures
Fall 2015
Homework 9
Instructor: Lorenzo Orecchia
Due: Tuesday, November 24 at 5pm
Reading Assignment:
MIT Notes Chapter 11
Assigned Exercises:
1. In a survey on the chewing gum preferences of baseball players, it was foun
CS 131: Combinatoric Structures
Fall 2015
Homework 10
Instructor: Lorenzo Orecchia
Due: Wednesday, December 3 at 11am
Reading Assignment:
MIT Notes Chapter 12.1, 12.2, 12.3, 12.4.112.4.3, 12.6
Assigned Exercises:
1. (a) Find the generating function for
CS 131_HW 3
1.
a)

Has Bugs

Needs Debugging
No bugs
Works
Correctly
Valid Conclusion
b)
A = Error in function A
B = Error in function B
A
B
AVB
T
T
T
T
F
T
F
T
T
F
F
F
Invalid Conclusion
c)
Can be represented as p/q
Rational Numbers
Integers
Valid Conc