Cub11k's BIU Notes
Cub11k's BIU Notes
Assignments
Discrete-math
Discrete-math 1
Discrete-math 10
Discrete-math 11
Discrete-math 12
Discrete-math 2
Discrete-math 3
Discrete-math 4
Discrete-math 5
Discrete-math 6
Discrete-math 7
Discrete-math 8
Discrete-math 9
Infi-1
Infi-1 10
Infi-1 11
Infi-1 2
Infi-1 3
Infi-1 4
Infi-1 5
Infi-1 6
Infi-1 7
Infi-1 8
Infi-1 9
Linear-1
Linear-1 1
Linear-1 10
Linear-1 11
Linear-1 12
Linear-1 2
Linear-1 3
Linear-1 4
Linear-1 5
Linear-1 6
Linear-1 7
Linear-1 8
Linear-1 9
Linear-2
Linear-2 1
Lectures
Data-structures
Data-structures 1
Data-structures 2
Data-structures 3
Discrete-math
Discrete-math 10
Discrete-math 11
Discrete-math 12
Discrete-math 13
Discrete-math 14
Discrete-math 15
Discrete-math 16
Discrete-math 18
Discrete-math 19
Discrete-math 20
Discrete-math 21
Discrete-math 22
Discrete-math 23
Discrete-math 24
Discrete-math 25
Discrete-math 26
Discrete-math 3
Discrete-math 4
Discrete-math 5
Discrete-math 6
Discrete-math 7
Discrete-math 8
Discrete-math 9
Exam 2023 (2A)
Exam 2023 (2B)
Exam 2023 (A)
Exam 2023 (B)
Exam 2023 (C)
Exam 2024 (A)
Exam 2024 (B)
Exam 2024 (C)
Midterm
Infi-1
Exam 2022B (A)
Exam 2022B (B)
Exam 2023B (A)
Exam 2023B (B)
Exam 2024 (A)
Exam 2024 (B)
Exam 2025 (A)
Infi-1 10
Infi-1 12
Infi-1 13
Infi-1 14
Infi-1 15
Infi-1 16
Infi-1 17
Infi-1 19
Infi-1 20
Infi-1 21
Infi-1 22
Infi-1 23
Infi-1 24
Infi-1 25
Infi-1 26
Infi-1 5
Infi-1 6
Infi-1 7
Infi-1 9
Midterm
Theorems and proofs
Infi-2
Infi-2 1
Infi-2 10
Infi-2 11
Infi-2 12
Infi-2 13
Infi-2 14
Infi-2 15
Infi-2 16
Infi-2 17
Infi-2 2-3
Infi-2 3-4
Infi-2 5
Infi-2 6
Infi-2 7
Infi-2 8
Infi-2 9
Linear-1
Exam 2023 (B)
Exam 2023 (C)
Exam 2024 (A)
Exam 2024 (B)
Exam 2024 (C)
Exam 2025 (A)
Linear-1 11
Linear-1 12
Linear-1 13
Linear-1 4
Linear-1 5
Linear-1 6
Linear-1 7
Linear-1 8
Linear-1 9
Midterm
Random exams
Theorems and proofs
Linear-2
Linear-2 1
Linear-2 2
Linear-2 3
Linear-2 4
Linear-2 5
Linear-2 6
Linear-2 7
Linear-2 8
Seminars
CSI
CSI 2
Data-structures
Data-structures 1
Data-structures 2
Data-structures 3
Discrete-math
Discrete-math 1
Discrete-math 10
Discrete-math 11
Discrete-math 12
Discrete-math 2
Discrete-math 3
Discrete-math 4
Discrete-math 5
Discrete-math 6
Discrete-math 7
Discrete-math 8
Discrete-math 9
Infi-1
Infi-1 10
Infi-1 11
Infi-1 12
Infi-1 13
Infi-1 3
Infi-1 4
Infi-1 5
Infi-1 6
Infi-1 8
Infi-2
Infi-2 1
Infi-2 2
Infi-2 3
Infi-2 4
Infi-2 6
Infi-2 7
Infi-2 8
Linear-1
Linear-1 10
Linear-1 11
Linear-1 12
Linear-1 3
Linear-1 5
Linear-1 6
Linear-1 7
Linear-1 8
Linear-1 9
Linear-2
Linear-2 1
Linear-2 2
Linear-2 3
Linear-2 4
Linear-2 5
Linear-2 6
Linear-2 7
Templates
Lecture Template
Seminar Template
Home
Discrete-math 11
1
Let
r
1
,
…
,
r
n
+
1
∈
[
0
,
1
)
⊆
R
Prove:
∃
1
≤
i
<
j
≤
n
+
1
:
|
r
i
−
r
j
|
<
1
n
Proof:
Let’s divide
[
0
,
1
)
into
n
half-closed intervals:
[
0
,
1
n
)
,
[
1
n
,
2
n
)
,
…
,
[
n
−
1
n
,
1
)
"Length" of each of these intervals is less than
1
n
Let
A
=
{
r
1
,
…
,
r
n
+
1
}
Let
B
=
{
[
0
,
1
n
)
,
[
1
n
,
2
n
)
,
…
,
[
n
−
1
n
,
1
)
}
Let
f
:
A
→
B
,
f
determines in which half-closed interval
x
is
|
A
|
=
n
+
1
>
n
=
|
B
|
⟹
By the pigeonhole principle, there are at least two numbers
r
i
,
r
j
(
i
<
j
)
in the same half-closed interval
⟹
k
n
≤
r
i
,
r
j
<
k
+
1
n
⟹
|
r
i
−
r
j
|
<
|
k
n
−
k
+
1
n
|
=
1
n
2a
Let
k
∈
N
Let
n
=
k
2
+
1
Let
A
be a set,
|
A
|
=
n
Let
{
A
i
}
i
=
1
k
be a partition of
A
into
k
sets
Prove:
∃
j
∈
[
1
,
k
]
:
|
A
j
|
≥
k
+
1
Proof:
Suppose
∀
j
∈
[
1
,
k
]
:
|
A
j
|
<
k
+
1
⟹
|
A
j
|
≤
k
{
A
i
}
i
=
1
k
is a partition
⟹
∀
i
≠
j
∈
[
1
,
k
]
:
A
i
∩
A
j
=
∅
⟹
|
⋃
i
=
1
k
A
i
|
=
∑
i
=
1
k
|
A
i
|
≤
k
2
By definition of partition:
⋃
i
=
1
k
A
i
=
A
⟹
|
⋃
i
=
1
k
A
i
|
=
|
A
|
=
n
=
k
2
+
1
⟹
k
2
+
1
≤
k
2
−
Contradiction!
⟹
∃
j
∈
[
1
,
k
]
:
|
A
j
|
≥
k
+
1
2b
Let
L
n
be a set of
2
n
+
1
lattice points in
R
n
Prove:
∃
p
,
q
∈
L
n
:
p
≠
q
∧
midpoint of
p
,
q
is also a lattice point
Proof:
Notation
P
(
x
)
is used as a parity predicate of
x
e.g.
P
(
27
)
=
F
,
P
(
2
)
=
T
Let
B
=
{
(
P
(
p
1
)
,
P
(
p
2
)
,
…
,
P
(
p
n
)
)
|
(
p
1
,
p
2
,
…
,
p
n
)
∈
L
n
}
In other words,
B
is a set of binary strings representing parity of a lattice point
Let
f
:
L
n
→
B
f
(
p
)
=
(
P
(
p
1
)
,
P
(
p
2
)
,
…
,
P
(
p
n
)
)
e.g. for
R
4
:
f
(
(
0
,
16
,
2
,
37
)
)
=
(
T
,
T
,
T
,
F
)
|
L
n
|
=
2
n
+
1
>
2
n
=
|
B
|
⟹
By the pigeonhole principle there exists at least two lattice points
p
,
q
such that:
f
(
p
)
=
f
(
q
)
Meaning:
∃
p
≠
q
∈
L
n
:
∀
i
∈
[
1
,
n
]
:
P
(
p
i
)
=
P
(
q
i
)
⟹
P
(
p
i
+
q
i
)
≡
T
⟹
p
i
+
q
i
2
∈
Z
⟹
Midpoint of
p
,
q
is a lattice point
3
Alice wants to register for a university where each course has only one lecture per week at
the same time. She needs to choose 7 courses from among 30 courses without overlap.
Given that each day, from Sunday to Thursday, has 6 courses (for a total of 30)
How many ways can Alice register for courses such that
she has at least one course each day?
Solution:
Let Alice ignore some days when choosing courses
If she ignores at least one day, then the number of ways to choose courses is:
(
30
−
6
7
)
If she ignores at least
k
days, then the number of ways to choose courses is:
(
30
−
6
k
7
)
Alice can ignore at most 3 days
⟹
by the Inclusion-Exclusion principle
The answer is:
∑
k
=
0
3
(
−
1
)
k
(
5
k
)
(
30
−
6
k
7
)
4
Let
S
=
{
1
,
2
,
.
.
.
,
500
}
How many integers in S are divisible by 2 or 3 or 5?
Solution:
Let
A
=
{
s
∈
S
|
2
∣
s
∨
3
∣
s
∨
5
∣
s
}
Number of integers in
S
divisible by 2 is:
⌊
500
2
⌋
=
250
Number of integers in
S
divisible by 3 is:
⌊
500
3
⌋
=
166
Number of integers in
S
divisible by 5 is:
⌊
500
5
⌋
=
100
Number of integers in
S
divisible by 2 and 3 is:
⌊
500
2
⋅
3
⌋
=
83
Number of integers in
S
divisible by 2 and 5 is:
⌊
500
2
⋅
5
⌋
=
50
Number of integers in
S
divisible by 3 and 5 is:
⌊
500
3
⋅
5
⌋
=
33
Number of integers in
S
divisible by 2, 3 and 5 is:
⌊
500
2
⋅
3
⋅
5
⌋
=
16
⟹
By the inclusion-exclusion principle:
|
A
|
=
|
A
2
|
+
|
A
3
|
+
|
A
5
|
−
|
A
23
|
−
|
A
25
|
−
|
A
35
|
+
|
A
235
|
=
=
250
+
166
+
100
−
83
−
50
−
33
+
16
⟹
|
A
|
=
366
5a
How many ways can 50 identical balls be distributed into 10 different boxes such that
Each box has at most
4
balls
Solution:
If each box has at most 4 balls, then total is at most
40
,
which is less than 50
⟹
The answer is
0
5b
How many ways can 50 identical balls be distributed into 10 different boxes such that
Each box has at most
5
balls
Solution:
If each box has at most 5 balls, then the total is at most
50
∑
i
=
1
10
x
i
=
50
Let
x
1
<
5
WLOG
⟹
∑
i
=
2
10
x
i
>
50
−
5
=
45
⟹
Some box has more than 5 balls
⟹
each box has exactly 5 balls
⟹
The answer is
1
5c
How many ways can 50 identical balls be distributed into 10 different boxes such that
Each box has at most
10
balls
Solution:
{
∑
i
=
1
10
x
i
=
50
∀
i
∈
[
1
,
10
]
:
x
i
≤
10
Let at least
k
boxes have more then 10 balls:
⟹
(
50
−
11
k
+
10
−
1
10
−
1
)
=
(
59
−
11
k
9
)
There are
(
10
k
)
ways to choose these
k
boxes
There are 50 balls
⟹
There are at least 0 and at most 4 boxes with 11 balls or more
⟹
#
of ways such that at least one box has more than 10 balls is:
By the inclusion-exclusion principle:
∑
k
=
1
4
(
−
1
)
k
+
1
(
10
k
)
(
59
−
11
k
9
)
(
−
1
)
k
+
1
is due to an inverted sign, because we’re counting the opposites
The total # of ways to distribute 50 balls into 10 boxes is:
(
50
+
10
−
1
10
−
1
)
=
(
59
9
)
⟹
The final answer is:
(
59
9
)
−
∑
k
=
1
4
(
−
1
)
k
+
1
(
10
k
)
(
59
−
11
k
9
)
This can be rewritten as:
∑
k
=
0
4
(
−
1
)
k
(
10
k
)
(
59
−
11
k
9
)
5d
How many ways can 50 identical balls be distributed into 10 different boxes such that
Each box has at most 12 balls and at least 2 balls
Solution:
Let’s factor out "at least 2":
∑
i
=
1
10
(
x
i
−
2
)
=
50
−
20
=
30
Now there are 2 balls in each box, for some to have 13, they need 11 more
Let’s use the same rhetoric as in 5c
This time the total is 30 balls, not 50, so we can only get 2 boxes to have 11 balls or more
∑
k
=
0
2
(
−
1
)
k
(
30
−
11
k
+
10
−
1
10
−
1
)
(
10
k
)
=
∑
k
=
0
2
(
−
1
)
k
(
39
−
11
k
9
)
(
10
k
)
⟹
The final answer is:
∑
k
=
0
2
(
−
1
)
k
(
39
−
11
k
9
)
(
10
k
)
6
Let
n
∈
N
Suppose n people are standing in a line.
In how many ways can the people be arranged in line
such that no person stands in the same position they were in before?
Solution:
How many ways there are such that at least one person stays in his position?
One fixed position and
n
−
1
positions left to arrange:
(
n
−
1
)
!
How many ways there are such that at least
k
people stay in their position?
(
n
−
k
)
!
There are
(
n
k
)
ways to choose these
k
people
⟹
By the inclusion-exclusion principle the answer is:
∑
k
=
0
n
(
−
1
)
k
(
n
−
k
)
!
(
n
k
)
7
In the exam there are 15 questions numbered from 1 to 15.
Each question can either be answered correctly or incorrectly
We know that no student answered two consecutive questions correctly
There are 1600 students who took the exam
Must there be two students with identical answers or not?
Solution:
Consider a binary string of length 15
How many such strings can we produce without two consecutive ones?
Let
B
be such a string
B
=
(
b
1
,
b
2
,
…
,
b
15
)
Let
f
:
N
→
N
be a function, that counts the number of such strings
If
b
15
is a zero, then there are
f
(
14
)
possibilities for binary string
(
b
1
,
b
2
,
…
,
b
14
)
If
b
15
is a one, then
b
14
is a zero and there are
f
(
13
)
possibilities for binary string
(
b
1
,
b
2
,
…
,
b
13
)
⟹
f
(
15
)
=
f
(
14
)
+
f
(
13
)
In other words
f
(
n
)
=
f
(
n
−
1
)
+
f
(
n
−
2
)
or Fibonacci sequence
f
(
1
)
=
2
(strings 0 and 1), which is the 3rd Fibonacci number
f
(
2
)
=
3
(strings 00, 01 and 10), which is the 4th Fibonacci number
⟹
f
(
n
)
is
(
n
+
2
)
′
th Fibonacci number
⟹
f
(
15
)
=
F
(
17
)
=
1597
⟹
There are 1600 students and 1597 different exam answers
Let
A
be a set of students,
|
A
|
Let
C
be a set of possible exam answers,
|
C
|
=
1597
<
|
A
|
=
1600
Let
g
:
A
→
C
be a function mapping students to their exam answers
|
A
|
>
|
C
|
⟹
By the pigeonhole principle:
∃
a
1
,
a
2
∈
A
:
g
(
a
1
)
=
g
(
a
2
)
⟹
There are at least two students with the same answers
8
Let
A
,
B
be sets
|
A
|
=
n
,
|
B
|
=
k
,
k
≤
n
8a
How many injective functions
f
:
A
→
B
exist?
Solution:
If
k
<
n
,
then
|
A
|
>
|
B
|
⟹
There are 0 injective functions in
B
A
If
k
=
n
,
then there are exactly
n
!
injective functions in
B
A
⟹
The answer is:
n
!
8b
How many surjective functions
f
:
A
→
B
exist?
Solution:
There are a total of
k
n
functions in
B
A
Let’s count functions that do not map to at least
i
elements:
B
′
⊆
B
,
|
B
′
|
=
k
−
i
f
′
:
A
→
B
′
∈
B
′
A
,
|
B
′
A
|
=
(
k
−
i
)
n
There are
(
k
i
)
ways to choose these
i
elements
⟹
By the exclusion-inclusion principle # of surjective functions is:
∑
i
=
0
k
(
−
1
)
i
(
k
i
)
(
k
−
i
)
n
9
Let
p
1
,
…
,
p
n
∈
{
T
,
F
}
be logical propositions
Solution:
There are a total of
2
n
possible assignments for
p
1
,
…
,
p
n
Only one of them has zero Truths, when all propositions are False
⟹
The final answer is:
2
n
−
1
10a
Convert
(
p
→
(
q
∧
¬
r
)
)
∨
(
r
∧
p
)
into CNF and DNF
Solution:
Let
X
=
(
p
→
(
q
∧
¬
r
)
)
∨
(
r
∧
p
)
p
q
r
q
∧
¬
r
p
→
(
q
∧
¬
r
)
r
∧
p
X
0
0
0
0
1
0
1
0
0
1
0
1
0
1
0
1
0
1
1
0
1
0
1
1
0
1
0
1
1
0
0
0
0
0
0
1
0
1
0
0
1
1
1
1
0
1
1
0
1
1
1
1
0
0
1
1
⟹
CNF of
X
is:
(
¬
p
∨
q
∨
r
)
⟹
DNF of
X
is:
(
¬
p
)
∨
(
q
)
∨
(
r
)
10b
Convert
(
(
p
→
q
)
∨
¬
r
)
∧
(
p
↔
q
)
into CNF and DNF
Solution:
Let
X
=
(
(
p
→
q
)
∨
¬
r
)
∧
(
p
↔
q
)
p
q
r
p
→
q
(
p
→
q
)
∨
¬
r
p
↔
q
X
0
0
0
1
1
1
1
0
0
1
1
1
1
1
0
1
0
1
1
0
0
0
1
1
1
1
0
0
1
0
0
0
1
0
0
1
0
1
0
0
0
0
1
1
0
1
1
1
1
1
1
1
1
1
1
1
⟹
CNF of
X
is:
(
p
∨
¬
q
∨
r
)
∧
(
p
∨
¬
q
∨
¬
r
)
∧
(
¬
p
∨
q
∨
r
)
∧
(
¬
p
∨
q
∨
¬
r
)
Note that this can be simplified into:
(
p
∨
¬
q
)
∧
(
¬
p
∨
q
)
⟹
DNF of
X
is:
(
¬
p
∧
¬
q
∧
¬
r
)
∨
(
¬
p
∧
¬
q
∧
r
)
∨
(
p
∧
q
∧
¬
r
)
∨
(
p
∧
q
∧
r
)
Note that this can be simplified into:
(
¬
p
∧
¬
q
)
∨
(
p
∧
q
)
11a
Prove:
{
¬
,
→
}
is complete
Proof:
{
∧
,
∨
,
¬
}
is complete (there is a DNF for any proposition)
p
∧
q
=
¬
(
¬
p
∨
¬
q
)
⟹
{
∨
,
¬
}
is also complete
p
∨
q
=
¬
p
→
q
⟹
{
¬
,
→
}
is also complete
11b
Prove:
{
↑
}
is complete
Proof:
{
∧
,
∨
,
¬
}
is complete (there is a DNF for any proposition)
p
∨
q
=
¬
(
¬
p
∧
¬
q
)
⟹
{
∧
,
¬
}
is also complete
¬
p
=
p
↑
p
p
∧
q
=
¬
(
p
↑
q
)
=
(
p
↑
q
)
↑
(
p
↑
q
)
⟹
{
↑
}
is also complete
11c
Prove:
{
↓
}
is complete
Proof:
{
∧
,
∨
,
¬
}
is complete (there is a DNF for any proposition)
p
∧
q
=
¬
(
¬
p
∨
¬
q
)
⟹
{
∨
,
¬
}
is also complete
¬
p
=
p
↓
p
p
∨
q
=
¬
(
p
↓
q
)
=
(
p
↓
q
)
↓
(
p
↓
q
)
⟹
{
↓
}
is also complete