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 10
1
A person wants to choose 6 cookies from a tray containing at least 6 cookies
of each of the following types: chocolate chip, wheat, and peanut butter.
How many ways are there to choose these cookies?
Solution:
How many ways to choose one cookie is there?
3
There are at least 6 cookies of each type, so the number of ways
doesn’t change after choosing 1,2,3,4 or 5 cookies, so it is always
3
Order is not important and repetitions are allowed
⟹
(
6
+
3
−
1
3
−
1
)
=
(
8
2
)
2
How many ways are there to arrange number
{
1
,
2
,
…
,
9
}
such that
no multiple of 3 is adjacent to another multiple of 3?
Solution:
Let us first arrange numbers that are not multiples of 3 - 1, 2, 4, 5, 7, 8
There are six of them, which means there are
6
!
(
6
−
6
)
!
=
6
!
ways to arrange them
Now we have 6 numbers arranged and we need to choose 3 positions
among them for multiples of 3
There are 7 positions: 5 between chosen numbers and 2 on the sides
Each two multiples of 3 will then be separated by at least 1 other number
Number of ways to choose 3 out of these 7 positions is
7
!
(
7
−
3
)
!
=
7
!
4
!
The final answer is:
7
!
6
!
4
!
=
151200
3
There are 6 identical balls and 3 distinct boxes
3a
In how many ways can 6 balls be arranged in the 3 boxes?
Solution:
Each box can be represented as a variable in the equation:
x
1
+
x
2
+
x
3
=
6
,
∀
i
∈
[
1
,
3
]
:
x
i
≥
0
Number of different solutions is:
(
6
+
3
−
1
3
−
1
)
=
(
8
2
)
3b
In how many ways can 6 balls be arranged in the 3 boxes
such that each box contains at least one ball?
Solution:
x
1
+
x
2
+
x
3
=
6
,
∀
i
∈
[
1
,
3
]
:
x
i
≥
1
⟹
(
x
1
−
1
)
+
(
x
2
−
1
)
+
(
x
3
−
1
)
=
3
,
∀
i
∈
[
1
,
3
]
:
x
i
−
1
≥
0
Number of different solutions is:
(
3
+
3
−
1
3
−
1
)
=
(
5
2
)
3c
Now there are 7 balls. In how many ways can they be arranged in the 3 boxes
such that no box contains more than 4 balls
Solution:
x
1
+
x
2
+
x
3
=
7
,
∀
i
∈
[
1
,
3
]
:
0
≤
x
i
≤
4
Let’s solve an "inverse" problem:
x
1
+
x
2
+
x
3
=
7
,
x
1
≥
5
∨
x
2
≥
5
∨
x
3
≥
5
Note that only one of the variables can be greater than
4
at the same time
⟹
There are 3 different problems with the same number of solutions:
(
x
i
−
5
)
+
x
j
+
x
k
=
2
,
x
i
−
5
,
x
j
,
x
k
≥
0
⟹
3
⋅
(
2
+
3
−
1
3
−
1
)
=
3
⋅
(
4
2
)
⟹
Number of solutions to the initial problem is:
(
3
+
7
−
1
3
−
1
)
−
3
⋅
(
4
2
)
=
(
9
2
)
−
3
⋅
(
4
2
)
3d
Now there are 8 balls, 4 boxes labeled A, B, C, D
How many ways to arrange the balls there are such that:
1.
Each box contains at least 1 ball
2.
Each box contains no more than 4 balls
3.
Boxes A and B together contain exactly 5 balls
Solution:
Let
x
1
,
x
2
,
x
3
,
x
4
correspond to boxes
A
,
B
,
C
,
D
accordingly
⟹
{
x
1
+
x
2
+
x
3
+
x
4
=
8
∀
i
∈
[
1
,
4
]
:
1
≤
x
i
≤
4
x
1
+
x
2
=
5
⟹
{
x
1
+
x
2
=
5
x
3
+
x
4
=
3
∀
i
∈
[
1
,
4
]
:
1
≤
x
i
≤
4
x
1
+
x
2
=
5
,
x
1
,
x
2
≥
1
⟹
There are no solutions where
x
1
or
x
2
are greater than
4
⟹
(
x
1
−
1
)
+
(
x
2
−
1
)
=
3
,
(
x
1
−
1
)
,
(
x
2
−
1
)
≥
0
⟹
(
3
+
2
−
1
2
−
1
)
=
(
4
1
)
x
3
+
x
4
=
3
,
x
3
,
x
4
≥
1
⟹
There are no solutions where
x
3
or
x
4
are greater than
4
⟹
(
x
3
−
1
)
+
(
x
4
−
1
)
=
1
,
(
x
3
−
1
)
,
(
x
4
−
1
)
≥
0
⟹
(
1
+
2
−
1
2
−
1
)
=
(
2
1
)
⟹
The final answer is
(
4
1
)
⋅
(
2
1
)
4
Let
x
,
y
,
n
∈
N
∪
{
0
}
n
≤
x
,
n
≤
y
Prove combinatorially:
(
x
+
y
n
)
=
∑
k
=
0
n
(
x
k
)
(
y
n
−
k
)
Proof:
Let us choose
n
people from
x
boys and
y
girls:
(
x
+
y
n
)
Let us now choose
k
boys first and then choose the girls left
A
k
=
{
ways to choose
k
from
x
boys and
n
−
k
from
y
girls
}
|
A
k
|
=
(
x
k
)
⋅
(
y
n
−
k
)
i
≠
j
⟹
A
i
∩
A
j
=
∅
|
⋃
k
=
0
n
A
k
|
=
∑
k
=
0
n
|
A
k
|
=
∑
k
=
0
n
(
x
k
)
⋅
(
y
n
−
k
)
⟹
(
x
+
y
n
)
=
∑
k
=
0
n
(
x
k
)
(
y
n
−
k
)
5
Let
n
∈
N
Prove algebraically and combinatorially:
∑
k
=
1
n
k
⋅
k
!
=
(
n
+
1
)
!
−
1
Proof (algebraic):
(
n
+
1
)
!
−
1
=
(
n
+
1
)
n
!
−
1
=
n
⋅
n
!
+
n
!
−
1
⟹
∑
k
=
1
n
k
⋅
k
!
=
∑
k
=
1
n
(
k
⋅
k
!
+
k
!
−
1
)
−
∑
k
=
1
n
(
k
!
−
1
)
=
∑
k
=
1
n
(
(
k
+
1
)
!
−
1
−
k
!
+
1
)
=
=
∑
k
=
1
n
(
k
+
1
)
!
−
k
!
=
2
!
−
1
!
+
3
!
−
2
!
+
⋯
+
(
n
+
1
)
!
−
n
!
=
(
n
+
1
)
!
−
1
!
=
(
n
+
1
)
!
−
1
⟹
∑
k
=
1
n
k
⋅
k
!
=
(
n
+
1
)
!
−
1
Proof (combinatorial):
Let
A
=
(
1
,
2
,
…
,
n
+
1
)
There are
(
n
+
1
)
!
permutations of this ordered list
Let us count all possible permutations except for the trivial (sorted) one
There are
(
n
+
1
)
!
−
1
of them
Let us now choose number
k
between 1 and
n
1.
Let us choose one item from
k
first items and swap it with
(
k
+
1
)
’th item
There are
k
ways to do so
2.
Let us now count all possible permutations of first
k
items
There are
k
!
such permutations
Let
A
k
=
{
permutations generated with steps 1 and 2
}
Let
i
<
j
(
symmetrical cases
)
A
i
∩
A
j
=
∅
because in any permutation of
A
i
,
(
j
+
1
)
’th element is equal to
(
j
+
1
)
And in any permutations of
A
j
,
(
j
+
1
)
’th element is not equal to
(
j
+
1
)
⟹
|
U
k
=
1
n
A
k
|
=
∑
k
=
1
n
|
A
k
|
=
∑
k
=
1
n
k
⋅
k
!
Let
P
be a set of all non-trivial permutations
U
k
=
1
n
A
k
⊆
P
is obvious
This is because
∀
i
∈
[
1
,
n
]
:
∀
p
∈
A
i
:
p
i
+
1
≠
i
+
1
Let
p
∈
P
There is a non-trivial part of
p
and there is a trivial part of
p
Let the length of a non-trivial part of
p
be
k
+
1
Then
p
∈
A
k
⟹
P
⊆
U
k
=
1
n
A
k
⟹
U
k
=
1
n
A
k
is a set of all possible permutations of
A
except the trivial one
⟹
|
U
k
=
1
n
A
k
|
=
(
n
+
1
)
!
−
1
⟹
∑
k
=
1
n
k
⋅
k
!
=
(
n
+
1
)
!
−
1
6
Let
A
,
B
⊆
R
|
A
|
=
n
≤
k
=
|
B
|
6a
How many functions
f
:
A
→
B
exist such that:
∀
a
1
,
a
2
∈
A
:
a
1
<
a
2
→
f
(
a
1
)
<
f
(
a
2
)
Solution:
Elements of
A
are strictly ordered by
<
on
R
Elements of
B
are also strictly ordered by
<
on
R
Thus to satisfy the condition we must simply choose
n
different images in
B
⟹
The answer is:
(
k
n
)
6b
How many functions
f
:
A
→
B
exist such that:
∀
a
1
,
a
2
∈
A
:
a
1
<
a
2
→
f
(
a
1
)
≤
f
(
a
2
)
Solution:
Rhetoric is the same as in 6a, but this time repetitions are allowed
⟹
The answer is:
(
n
+
k
−
1
k
−
1
)
7
Let
n
∈
N
∪
{
0
}
Prove algebraically and combinatorially:
∑
k
=
0
n
3
k
(
n
k
)
=
4
n
Proof (algebraic):
By the binomial theorem:
4
n
=
(
1
+
3
)
n
=
∑
k
=
0
n
1
n
−
k
3
k
(
n
k
)
=
∑
k
=
0
n
3
k
(
n
k
)
⟹
∑
k
=
0
n
3
k
(
n
k
)
=
4
n
Proof (combinatorial):
Let us construct a
n
-long string consisting of numbers 1, 2, 3, 4
Number of ways to construct such a string is
4
n
Let us now first choose number
0
≤
k
≤
n
1.
Let us choose
n
−
k
places for 1’s, there are
(
n
k
)
ways to do so
2.
For the left
k
places we need to choose either 2, 3 or 4
There are
3
k
ways to do this
Let
A
k
=
{
strings constructed using steps 1 and 2
}
i
≠
j
⟹
A
i
∩
A
j
=
∅
because the amount of 1’s is different
⟹
|
U
k
=
0
n
A
k
|
=
∑
k
=
0
n
|
A
k
|
=
∑
k
=
0
n
3
k
(
n
k
)
⋃
k
=
0
n
A
k
is a set of all possible
n
-long strings of numbers 1, 2, 3, 4
⟹
There are
∑
k
=
0
n
3
k
(
n
k
)
ways to construct a
n
-long string of numbers 1, 2, 3, 4
⟹
∑
k
=
0
n
3
k
(
n
k
)
=
4
n
8
Let
n
∈
N
∪
{
0
}
Prove combinatorially:
∑
k
=
0
2
n
k
(
2
n
k
)
=
2
n
⋅
2
2
n
−
1
Proof (combinatorial):
If
n
=
0
,
then both sides are equal to
0
If
n
∈
N
:
X
ways how to choose a team:
1.
Choose a captain from
2
n
players
2.
Choose a subset of left players to join the captain
X
=
2
n
⋅
2
2
n
−
1
Y
ways to choose a team:
1.
Choose a subset of
k
players from
2
n
players
2.
Choose one of the players in the team to be captain
k
ranges from
0
to
2
n
⟹
Y
=
∑
k
=
0
2
n
(
(
2
n
k
)
⋅
k
)
X
=
Y
⟹
∑
k
=
0
2
n
k
(
2
n
k
)
=
2
n
⋅
2
2
n
−
1
P. S. This is also known as Captain’s identity
9
Let
n
,
m
∈
N
∪
{
0
}
n
≤
m
Prove combinatorially:
∑
k
=
0
n
(
n
k
)
(
m
+
k
n
)
=
∑
k
=
0
n
(
n
k
)
(
m
k
)
2
k
10a
Let
n
∈
N
Prove combinatorially:
∑
k
=
0
n
k
(
n
k
)
=
n
⋅
2
n
−
1
Proof:
See task 8, it is identical
10b
Let
n
∈
N
Prove combinatorially:
∑
k
=
0
n
k
(
k
−
1
)
(
n
k
)
=
n
(
n
−
1
)
⋅
2
n
−
2
Proof:
Another variation of Captain’s identity
but now we choose a captain and his second-in-command, who must be a different person
10c
Let
n
∈
N
Prove algebraically or combinatorially:
∑
k
=
0
n
k
2
(
n
k
)
=
n
(
n
+
1
)
2
n
−
2
Proof:
k
(
n
k
)
=
n
(
n
−
1
k
−
1
)
⟹
∑
k
=
0
n
k
2
(
n
k
)
=
n
∑
k
=
0
n
k
(
n
−
1
k
−
1
)
k
=
0
does not affect the sum
⟹
∑
k
=
0
n
k
(
n
−
1
k
−
1
)
=
∑
k
=
1
n
k
(
n
−
1
k
−
1
)
=
∑
t
=
0
n
−
1
(
t
+
1
)
(
n
−
1
t
)
=
∑
t
=
0
n
−
1
t
(
n
−
1
t
)
+
∑
t
=
0
n
−
1
(
n
−
1
t
)
∑
t
=
0
n
−
1
t
(
n
−
1
t
)
=
(
n
−
1
)
⋅
2
n
−
2
∑
t
=
0
n
−
1
(
n
−
1
t
)
=
2
n
−
1
⟹
∑
k
=
0
n
k
(
n
−
1
k
−
1
)
=
(
n
−
1
)
⋅
2
n
−
2
+
2
n
−
1
=
(
n
−
1
+
2
)
⋅
2
n
−
2
=
(
n
+
1
)
2
n
−
2
∑
k
=
0
n
k
2
(
n
k
)
=
n
∑
k
=
0
n
k
(
n
−
1
k
−
1
)
⟹
∑
k
=
0
n
k
2
(
n
k
)
=
n
(
n
+
1
)
2
n
−
2
11a
Let
n
∈
N
How many ways there are to divide 2n tennis players into pairs for the tournament?
Solution:
We need to split
2
n
players into
n
pairs
Order of pairs does not matter
Order inside the pairs also does not matter
So we simply need to calculate the number of ways to choose 2 different players from
2
n
and do so
n
times
Order of pairs doesn’t matter too, so we should divide by
n
!
Which is
(
2
n
2
,
2
,
…
,
2
)
n
!
=
2
n
!
n
!
⋅
(
2
!
)
n
=
(
2
n
)
!
n
!
⋅
2
n
11b
Let
n
∈
N
Prove combinatorially:
(
2
n
)
!
n
!
⋅
2
n
=
1
⋅
3
⋅
5
⋯
⋅
(
2
n
−
1
)
Proof:
Let us think about left side in terms of task 11a:
Let us reorder
2
n
players, there are
(
2
n
)
!
ways to do so
Let us now treat each two players as a pair
Note that the order of pairs doesn’t matter, so we divide by
n
!
Note that in each pair order also doesn’t matter, so we divide
n
times by
2
The final formula for the amount of pairs is:
(
2
n
)
!
n
!
⋅
2
n
Let us now think about the right side:
How many ways to choose a partner does the first person have?
2
n
−
1
There are now
2
n
−
2
players without partners
How many way to choose a partner does the second person have?
2
n
−
3
This process will continue until the last two persons form a pair
The final formula for the amount of pairs is:
(
2
n
−
1
)
⋅
(
2
n
−
3
)
⋅
…
⋅
3
⋅
1
⟹
(
2
n
)
!
n
!
⋅
2
n
=
1
⋅
3
⋅
5
⋯
⋅
(
2
n
−
1
)
12
Let
n
∈
N
Prove combinatorially:
∑
k
=
1
n
−
1
(
n
−
k
)
2
(
n
−
1
n
−
k
)
=
n
(
n
−
1
)
⋅
2
n
−
3
Proof:
Let
t
=
k
−
1
∑
k
=
1
n
−
1
(
n
−
k
)
2
(
n
−
1
n
−
k
)
=
∑
t
=
0
n
−
2
(
n
−
1
−
t
)
2
(
n
−
1
n
−
1
−
t
)
=
∑
t
=
0
n
−
2
(
n
−
1
−
t
)
2
(
n
−
1
t
)
Suppose there are
n
−
1
people
We would like to choose a team of at most
n
−
2
sailors, led by a captain and a navigator
The same person can be both captain and navigator
Let us first choose
t
people for the team, there are
(
n
−
1
t
)
ways to do so
Let us then choose a captain and a navigator from
n
−
1
−
t
people left
They can be the same person, so the number of ways to do so is:
(
n
−
1
−
t
)
2
The final formula would then be:
∑
t
=
0
n
−
2
(
n
−
1
−
t
)
2
(
n
−
1
t
)
n
(
n
−
1
)
⋅
2
n
−
3
=
(
n
−
2
+
2
)
(
n
−
1
)
⋅
2
n
−
3
=
(
n
−
2
)
(
n
−
1
)
⋅
2
n
−
3
+
(
n
−
1
)
⋅
2
n
−
2
Let us now first choose a captain and a navigator:
1.
Choose two different persons -
(
n
−
1
)
(
n
−
2
)
2.
Choose one person for both -
(
n
−
1
)
And then choose a team of sailors to join them:
1.
If captain and navigator are two persons
there are
n
−
3
people left to choose from:
2
n
−
3
2.
If captain and navigator are the same person
there are
n
−
2
people left to choose from:
2
n
−
2
The final formula would then be:
(
n
−
2
)
(
n
−
1
)
⋅
2
n
−
3
+
(
n
−
1
)
⋅
2
n
−
2
⟹
∑
k
=
1
n
−
1
(
n
−
k
)
2
(
n
−
1
n
−
k
)
=
∑
t
=
0
n
−
2
(
n
−
1
−
t
)
2
(
n
−
1
t
)
=
=
(
n
−
2
)
(
n
−
1
)
⋅
2
n
−
3
+
(
n
−
1
)
⋅
2
n
−
2
=
n
(
n
−
1
)
⋅
2
n
−
3
⟹
∑
k
=
1
n
−
1
(
n
−
k
)
2
(
n
−
1
n
−
k
)
=
n
(
n
−
1
)
⋅
2
n
−
3