Discrete math exam
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,578 @@
|
||||
#import "@local/dtu-template:0.5.1":*
|
||||
#import "@preview/cetz:0.4.2"
|
||||
#import "@preview/cetz-venn:0.1.4": venn2, venn3
|
||||
#import "@preview/auto-div:0.1.0": poly-div, poly-div-working
|
||||
|
||||
#let mark-circle = box(width: 0.8em, height: 0.8em, stroke: 0.5pt + black, radius: 50%)
|
||||
#let ans(body) = grid(columns: (auto, 1fr), column-gutter: 0.5em, align: (center, left), mark-circle, body)
|
||||
|
||||
#let corr-circle = box(width: 0.8em, height: 0.8em, stroke: 0.5pt + black, fill: black, radius: 50%)
|
||||
#let corr(body) = grid(columns: (auto, 1fr), column-gutter: 0.5em, align: (center, left), corr-circle, body)
|
||||
|
||||
#show heading: it => { pagebreak(weak: true); it }
|
||||
== Question 1
|
||||
|
||||
If $p,q$ are prime numbers such that $100 < p < q$, then the number of positive integers less than $p q$ which are relative prime to $p q$ is:
|
||||
|
||||
#corr[$p q - p - q + 1$ (Rasmus's, Sebastian's answer)]
|
||||
#ans[$p q - q + 1$]
|
||||
#ans[$p q-p-q-1$]
|
||||
#ans[$p q-p-q$ (Mikkel's answer)]
|
||||
#ans[$p q-1$]
|
||||
#ans[None of these]
|
||||
|
||||
== Question 2
|
||||
|
||||
The number $(4^100 mod 6 )^100 mod 10$ equals
|
||||
|
||||
#ans[3]
|
||||
#corr[6 (All's answer)]
|
||||
#ans[2]
|
||||
#ans[None of these]
|
||||
#ans[5]
|
||||
#ans[1]
|
||||
#ans[4]
|
||||
|
||||
== Question 3
|
||||
|
||||
Consider the set of all 99 positive integers not exceeding 99.
|
||||
|
||||
#table(
|
||||
columns: (18%, auto, auto, auto, auto, auto, auto, auto, auto),
|
||||
align: (left, center, center, center, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[],
|
||||
[$binom(99, 50)$],
|
||||
[$2^98$],
|
||||
[$2^97$],
|
||||
[$2^49$],
|
||||
[None of these],
|
||||
[$2^50$],
|
||||
[$binom(99,50) binom(99,49)$],
|
||||
[$binom(99,49) binom(99, 49)$],
|
||||
[How many subsets have an odd number of odd numbers, and an even number of even numbers?],
|
||||
mark-circle,
|
||||
[Mikkel's answer],
|
||||
[*Sebastian's answer*],
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[How many subsets have an odd number of even numbers and an even number of odd numbers?],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
[Rasmus's answer],
|
||||
[Sebastian's answer],
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[How many subsets have 49 elements?],
|
||||
[*Rasmus's answer*],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's, Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[How many subsets have an odd number of odd numbers?],
|
||||
mark-circle,
|
||||
[*Rasmus's, Sebastian's answer*],
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
== Question 4
|
||||
|
||||
Consider the following system of congruences:
|
||||
|
||||
$
|
||||
x &equiv 1 mod 2 \
|
||||
x &equiv 1 mod 5 \
|
||||
x &equiv 7 mod 9
|
||||
$
|
||||
|
||||
Indicate the set of all solutions to the above system of congruences.
|
||||
|
||||
#ans[None of these]
|
||||
#ans[${90 + 7k | k in ZZ}$]
|
||||
#ans[${1 + 2k | k in ZZ} union {1 + 5k | k in ZZ} union {7 + 9k | k in ZZ}$]
|
||||
#ans[${9 + 90k | k in ZZ}$]
|
||||
#corr[${61 + 90k | k in ZZ}$ (All's answer)]
|
||||
#ans[${7 + 90k | k in ZZ}$]
|
||||
|
||||
|
||||
== Question 5
|
||||
|
||||
Find a greatest common divisor of the polynomials $x^3 - 1$ and $x^3 + 2x^2 + 2x + 1$
|
||||
|
||||
#ans[$x+1$]
|
||||
#ans[$1$(Mikkel's answer)]
|
||||
#ans[$x-1$]
|
||||
#corr[$x^2 + x + 1$ (Rasmus's, Sebastian's answer)]
|
||||
#ans[$x^2 + x - 1$]
|
||||
#ans[None of these]
|
||||
#ans[$x^2 - x + 1$]
|
||||
#ans[$x^2-x-1$]
|
||||
|
||||
|
||||
== Question 6
|
||||
|
||||
Recall that $NN$ is the set of natural numbers, in other words the set of nonnegative integers. For all $n in NN$ define $f(n) = sum^n_(k=0) k dot k! = 0 dot 0! + 1 dot !+ dots + n dot n!$. It is possible to prove by induction that $f(n) = (n+1)! -1$ holds for all nonnegative integers $n$.
|
||||
|
||||
By choosing 4 of the following 8 text fragments and putting them in the correct order, a proof by induction for the above statement can be created.
|
||||
|
||||
A. To prove the induction step, we assume that $f(n+1) = ((n+1)+1)!-1$ holds for some $n in NN$. We will now prove that under this assumption, $f(n) = (n+1)!-1$
|
||||
|
||||
B. To prove the induction step we assume that $f(n) = (n+1)!-1$ holds for all $n in NN$. We will now prove that under this assumption, $f(n+1) = ((n+1)+1)!-1$ holds for all $n in NN$.
|
||||
|
||||
C. To prove the induction step we assume that $f(n) = (n+1)!-1$ holds for some $n in NN$. We will now prove that under this assumption, $f(n+1) = ((n+1)+1)!-1$.
|
||||
|
||||
D. The statement now follows from the principle of mathematical induction.
|
||||
|
||||
E. We prove the statement by induction. The base case is $n = 1$. For $n=1$, we see that $f(1) = sum^1_(k=0)k dot k! = 0 dot 0! + 1 dot 1! = 0 dot 1 + 1 dot 1 = 1$ and also that $(n+1)! -1 = (1+1)!-1 = 2!-1 = 2-1 =1$. This proves the base case.
|
||||
|
||||
F. We prove the statement by induction. The base case is $n=0$. For $n=0$, we see that $f(0) = sum^0_(k=0) k dot k! = 0 dot 0! = 0 dot 1 = 0$ and also that $(n+1)! -1 = (0+1)!-1 = 1!-1 = 1-1 =0$. This proves the base case.
|
||||
|
||||
|
||||
G. We have that $
|
||||
f(n) &= sum^n_(k=0) k dot k! \
|
||||
&= (sum^(n+1)_(k=0) k dot k! ) - (n+1)(n+1)! \
|
||||
&= f(n+1) - (n+1)(n+1)! \
|
||||
&= ((n+1)+1)! - 1 - (n+1)(n+1)! "By the induction hypothesis" \
|
||||
&= (n+2)! -(n+1)(n+1)!-1 \
|
||||
&= (n+2)(n+1)!-(n+1)(n+1)!-1 \
|
||||
&= (n+2 - (n+1))(n+1)!-1 \
|
||||
&= (n+1)! -1
|
||||
$ which is what we wanted to prove. This concludes the induction step.
|
||||
|
||||
H. We have that $
|
||||
f(n+1) &= sum^(n+1)_(k=0) k dot k! \
|
||||
&= (sum^n_(k=0) k dot k!) + (n+1)(n+1)! \
|
||||
&= f(n)+(n+1)(n+1)! \
|
||||
&= (n+1)!-1+(n+1)(n+1)! "By the induction hypothesis" \
|
||||
&= (n+1)(n+1)!+(n+1)!-1 \
|
||||
&= [(n+1)+1](n+1)!-1 \
|
||||
&= (n+2)! - 1 = ((n+1)+1)!-1
|
||||
$ which is what we wanted to prove. This concludes the induction step.
|
||||
|
||||
#table(
|
||||
columns: (20%, auto, auto, auto, auto, auto, auto, auto, auto),
|
||||
align: (left, center, center, center, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[],
|
||||
[A],
|
||||
[B],
|
||||
[C],
|
||||
[D],
|
||||
[E],
|
||||
[F],
|
||||
[G],
|
||||
[H],
|
||||
[The first fragment is:],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's, Sebastian's answer],
|
||||
[*Rasmus's answer*],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[The second fragment is:],
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
[*Rasmus's answer*],
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[The third fragment is:],
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[*Rasmus's answer*],
|
||||
[The fourth fragment is:],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[*Rasmus's answer*],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
[Mikkel's answer],
|
||||
)
|
||||
|
||||
== Question 7
|
||||
|
||||
For all $n in NN$ define $a_n$ recursively as follows $a_0 = 2, a_1 = 3, a_n = cases(a_(n-1) + n "if" n "is even", a_(n-1) + 2a_(n-2) "if" n "is odd")$
|
||||
|
||||
#corr[37 (All's answer)]
|
||||
#ans[38]
|
||||
#ans[35]
|
||||
#ans[40]
|
||||
#ans[None of these]
|
||||
#ans[36]
|
||||
#ans[39]
|
||||
|
||||
== Question 8
|
||||
|
||||
We wish to construct a bipartite graph with bipartition $(V_1, V_2)$ such that $abs(V_1) = 4, abs(V_2) = 5$ (Note that a bipartite graph has no loops, but it may contain multiple edges.)
|
||||
#table(
|
||||
columns: (40%, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center),
|
||||
[],
|
||||
[The graph exists without multiple edges.],
|
||||
[The graph exists but only if we allow multiple edges.],
|
||||
[The graph does not exist, but it will exist if we are allowed to increase one of the degrees in $V_1$.],
|
||||
[The graph does not exist, but it will exist if we are allowed to increase one of the degrees in $V_2$.],
|
||||
[None of these are correct],
|
||||
[If the degrees in $V_1$ are $5,5,5,5$ and the degrees in $V_2$ are $4,4,4,4,4$ then],
|
||||
[*Rasmus's answer*],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's, Sebastian's answer],
|
||||
mark-circle,
|
||||
[If the degrees in $V_1$ are $1,2,2,2$ and the degrees in $V_2$ are $1,2,2,2,2$ then],
|
||||
[Sebastian's answer],
|
||||
[Mikkel's answer],
|
||||
[*Rasmus's answer*],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[If the degrees in $V_1$ are $4,4,4,4$, and the degrees in $V_2$ are $5,5,5,5,5$ then],
|
||||
mark-circle,
|
||||
[Rasmus's answer],
|
||||
[Mikkel's, Sebastian's answer],
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
|
||||
== Question 9
|
||||
|
||||
The formula $binom(m+n, r) = sum^r_(k=a) binom(m, r-k) binom(n,k)$ is true for all integers $m,n,r$ satisfying $0 < m < r < n$ if we let the summation start with:
|
||||
|
||||
#ans[$a = n$ (Sebastian's answer)]
|
||||
#ans[$a = r$]
|
||||
#ans[None of these (Rasmus's answer)]
|
||||
#ans[$a = n -r$ (Mikkel's answer)]
|
||||
#ans[$a = m$]
|
||||
#corr[$a = r - m$]
|
||||
|
||||
|
||||
== Question 10
|
||||
|
||||
Let $A = {0,1,2,4}, B = {0,1,3,5}, "and" C = {0,2,3,6}$. IF the universal set $U = {0,1,2,3,4,5,6,7}$, then which of the following is equal to $((A inter B) backslash C) union ((B inter C) backslash A) union ((C inter A) backslash B)$
|
||||
|
||||
#ans[${0,1,2,3}$]
|
||||
#ans[All of these sets]
|
||||
#ans[$emptyset$ (Mikkel's answer)]
|
||||
#ans[${4,5,6}$]
|
||||
#ans[None of these ]
|
||||
#ans[${0,4,5,6}$]
|
||||
#corr[${1,2,3}$ (Rasmus's, Sebastian's answer)]
|
||||
|
||||
== Question 11
|
||||
|
||||
Consider the statement "for every positive rational number $x$ there are positive integers $a$ and $b$ such that $x = a/b$ and $gcd(a,b) = 1$." Which of the following statement in predicate logic is equivalent to this if we let $G(a,b)$ denote the statement " $a "and" b$ are relatively prime"?
|
||||
|
||||
#ans[It is not possible to translate the statement into predicate logic. (Sebastian's answer)]
|
||||
#corr[$forall x in QQ^+ exists a in ZZ^+ exists b in ZZ^+ (x = a/b and G(a,b)) $ (Mikkel's, Rasmus's answer)]
|
||||
#ans[$forall x in QQ^+ exists a in ZZ^+ exists b in ZZ^+ (G(a,b) -> x = a/b)$]
|
||||
#ans[$forall x in QQ^+ forall a in ZZ^+ forall b in ZZ^+ (x = a/b and G(a,b))$]
|
||||
#ans[$forall x in QQ^+ exists a in ZZ^+ exists b in ZZ^+ (x = a/b -> G(a,b))$]
|
||||
|
||||
== Question 12
|
||||
|
||||
Given a univerisal set $U$, which of the following is equal to the set $A inter overline((B backslash C))$?
|
||||
|
||||
#ans[None of these]
|
||||
#ans[$A inter B inter overline(C)$]
|
||||
#ans[$(A union B) inter (A union overline(C))$]
|
||||
#corr[$(A inter overline(B)) union (A inter C)$ (Rasmus's answer)]
|
||||
#ans[$A inter overline(B) inter C$]
|
||||
#ans[$A inter (C backslash B)$ (Mikkel's, Sebastian's answer)]
|
||||
|
||||
|
||||
== Question 13
|
||||
|
||||
The empty set is an element of which of the following sets?
|
||||
|
||||
#ans[${{emptyset}}$]
|
||||
#ans[None of these]
|
||||
#ans[$emptyset$ (Mikkel's answer)]
|
||||
#ans[${x in RR : x < x}$]
|
||||
#corr[${emptyset}$ (Rasmus's, Sebastian's answer)]
|
||||
#ans[All of these sets]
|
||||
|
||||
== Question 14
|
||||
|
||||
Which of the following are tautologies?
|
||||
|
||||
#ans[$(p -> q) or (not q -> not p)$ (Sebastian's answer)]
|
||||
#ans[None of these]
|
||||
#ans[$p <-> q$]
|
||||
#ans[All of these]
|
||||
#corr[$(not p or not q) -> (not (p and q))$ (Mikkel's, Rasmus's answer)]
|
||||
#ans[$(p or q or r) and (p or not q or not r)$]
|
||||
|
||||
== Question 15
|
||||
|
||||
Consider all possible seatings of $3n$ people around two tables, one with $n$ seats and one with $2n$ seats. Find the number of seatings when
|
||||
#table(
|
||||
columns: (20%, auto, auto, auto, auto, auto, auto, auto, auto, auto),
|
||||
align: (left, center, center, center, center, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[],
|
||||
[$((3n)!)/(2(n!))$],
|
||||
[$((3n)!)/(4(n!))$],
|
||||
[$((3n)!)/(4n)$],
|
||||
[$2 binom(3n,n)$],
|
||||
[$((3n)!)/(2n^2)$],
|
||||
[$((3n)!)/(4n^2)$],
|
||||
[$((3n)!)/(8n^2)$],
|
||||
[$4 binom(3n,n)$],
|
||||
[None of these],
|
||||
[Two seatings are considered the same when each person has the same left and right neighbor.],
|
||||
mark-circle,
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
[Two seatings are considered the same when each person has the same neighbors (and we do not care about right or left)],
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's answer],
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
== Question 16
|
||||
|
||||
For each of the following, determine whether it is surjective/injective, or not a well defined function. Recall that $NN$ is the set of natural numbers, in other words the set of nonnegative integers.
|
||||
|
||||
#table(
|
||||
columns: (35%, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center),
|
||||
[],
|
||||
[Not a well defined function],
|
||||
[Well defined but neither injective nor surjective],
|
||||
[Surjective but not injective],
|
||||
[Injective but not surjective],
|
||||
[Both injective and surjective],
|
||||
[$ f: RR -> ZZ $ given by $f(x) = 2 floor(x/2)$],
|
||||
[Mikkel's, Sebastian's answer],
|
||||
[*Rasmus's answer*],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$f : RR -> {x in RR : x >= 0}$ given by $f(x) = sqrt(x^2)$],
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
[*Rasmus's answer*],
|
||||
mark-circle,
|
||||
[Mikkel's answer],
|
||||
[$f: NN -> NN$ given by $f(x) = 2x +7$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[*All's answer*],
|
||||
mark-circle,
|
||||
[$f: NN -> NN$ given by $f(x) = x-x^2$],
|
||||
[*Rasmus's, Sebastian's answer*],
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$f: RR -> RR$ given by $f(x) = cases(x "if" x in QQ, -x "if" x in.not QQ)$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's, Sebastian's answer],
|
||||
mark-circle,
|
||||
[*Rasmus's answer*],
|
||||
)
|
||||
|
||||
== Question 17
|
||||
|
||||
Consider all permutations of ABCDE
|
||||
#table(
|
||||
columns: (20%, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center, center, center),
|
||||
[],
|
||||
[12],
|
||||
[24],
|
||||
[36],
|
||||
[48],
|
||||
[50],
|
||||
[64],
|
||||
[None of these],
|
||||
[How many contain none of AB, BC, CD],
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
[*Rasmus's answer*],
|
||||
mark-circle,
|
||||
[How many contain ACE],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
[*Mikkel's, Rasmus's answer*],
|
||||
[How many contain precisely one of AB, CD],
|
||||
mark-circle,
|
||||
[Mikkels's, Sebastian's answer],
|
||||
[*Rasmus's answer*],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle
|
||||
)
|
||||
|
||||
== Question 18
|
||||
|
||||
For each relation on the set of four distinct elements $a,b,c,d$ below, decide which property it has.
|
||||
|
||||
#table(
|
||||
columns: (30%, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[],
|
||||
[The edges of a hasse diagram],
|
||||
[Partial order],
|
||||
[Total order but not well ordered],
|
||||
[Well-order],
|
||||
[None of these],
|
||||
[Total order but not partial order],
|
||||
[Equivalence relation],
|
||||
[$(a,a),(a,b),(a,c)(a,d)$],
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's answer],
|
||||
[*Rasmus's answer*],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$(a,b),(b,c),(c,d)$],
|
||||
corr-circle,
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's, Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$(a,a),(b,b),(c,c),\ (d,d),(a,d),(d,a)$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
[*Mikkel's, Rasmus's answer*],
|
||||
[$(a,a),(b,b),(c,c),\ (d,d),(d,c)$],
|
||||
mark-circle,
|
||||
[*Mikkel's, Rasmus's answer*],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
[$(a,a),(b,b),(c,c),(d,d),\ (a,b),(a,c),(a,d),(b,c),\ (b,d),(c,d)$],
|
||||
[Mikkel's answer],
|
||||
[Rasmus's answer],
|
||||
corr-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer]
|
||||
)
|
||||
Note: AI'er var uenige om den sidste, så har markeret de to svar jeg fik.
|
||||
|
||||
|
||||
== Question 19
|
||||
|
||||
Which of the following is a recursively defined function for the number of ways to tile an $n times 2$ board using $2 times 1$ tiles.
|
||||
|
||||
#corr[$f(0) = 1, f(1) = 1, f(n) = f(n - 1) + f(n - 2) "for" n >= 2$]
|
||||
#ans[$f(0) = 0, f(1) = 1, f(n) = 2f(n - 2) "for" n >= 2$]
|
||||
#ans[$f(0) = 1, f(1) = 1, f(n) = 2f(n - 2) "for" n >= 2$ (Rasmus's answer)]
|
||||
#ans[$f(0) = 1, f(1) = 1, f(n) = f(n - 1)f(n - 2) "for" n >= 2$]
|
||||
#ans[All of these (Mikkel's answer)]
|
||||
#ans[$f(0) = 0, f(1) = 1, f(n) = f(n - 1) + f(n - 2) "for" n >= 2$ (Sebastian's answer)]
|
||||
#ans[None of these ]
|
||||
|
||||
|
||||
== Question 20
|
||||
|
||||
Find the coefficient of $x^15 y^20$ in the polynomials below.
|
||||
|
||||
#table(
|
||||
columns: (20%, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center, center, center),
|
||||
[],
|
||||
[$- binom(10,5)2^5$],
|
||||
[$binom(10,5) 2^15$],
|
||||
[$- binom(10,5)2^15$],
|
||||
[0],
|
||||
[None of these],
|
||||
[$-binom(10,5)2^10$],
|
||||
[$- binom(10,3)2^5$],
|
||||
[$(2x^3-y^4)^10$],
|
||||
[*Mikkel's, Rasmus's answer*],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$(1-2x^3y^4)^10$],
|
||||
[*Rasmus's answer*],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$(x^3-2y^4)^10$],
|
||||
[*Mikkel's, Rasmus's answer*],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
|
||||
== Question 21
|
||||
|
||||
Which of the following is equivalent to the statement " $a$ and $b$ are relatively prime"? The domain for each statement is
|
||||
the set of all positive integers
|
||||
|
||||
#ans[None of these three are equivalent to the statement.]
|
||||
#ans[$not (exists c (c divides a and c divides b and c > 1) )$ is equivalent to the statement, and the other two are not. (Rasmus's answer)]
|
||||
#ans[$forall c (not (c divides a) or not (c divides b) or (c <= 1))$ is equivalent to the statement, and the other two are not.]
|
||||
#corr[All of these three are equivalent to the statement.]
|
||||
#ans[$forall c ( (c divides a and c divides b) -> (c <= 1))$ is equivalent to the statement, and other two are not. (Mikkel's, Sebastian's answer)]
|
||||
|
||||
12431
Diskret Mat/Gamle eksamener/Discrete Math exam Solutions by AI.pdf
Normal file
12431
Diskret Mat/Gamle eksamener/Discrete Math exam Solutions by AI.pdf
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,574 @@
|
||||
#import "@local/dtu-template:0.5.1":*
|
||||
#import "@preview/cetz:0.4.2"
|
||||
#import "@preview/cetz-venn:0.1.4": venn2, venn3
|
||||
#import "@preview/auto-div:0.1.0": poly-div, poly-div-working
|
||||
|
||||
#let mark-circle = box(width: 0.8em, height: 0.8em, stroke: 0.5pt + black, radius: 50%)
|
||||
#let ans(body) = grid(columns: (auto, 1fr), column-gutter: 0.5em, align: (center, left), mark-circle, body)
|
||||
|
||||
#let corr-circle = box(width: 0.8em, height: 0.8em, stroke: 0.5pt + black, fill: black, radius: 50%)
|
||||
#let corr(body) = grid(columns: (auto, 1fr), column-gutter: 0.5em, align: (center, left), corr-circle, body)
|
||||
|
||||
#show heading: it => { pagebreak(weak: true); it }
|
||||
== Question 1
|
||||
|
||||
If $p,q$ are prime numbers such that $100 < p < q$, then the number of positive integers less than $p q$ which are relative prime to $p q$ is:
|
||||
|
||||
#corr[$p q - p - q + 1$]
|
||||
#ans[$p q - q + 1$]
|
||||
#ans[$p q-p-q-1$]
|
||||
#ans[$p q-p-q$]
|
||||
#ans[$p q-1$]
|
||||
#ans[None of these]
|
||||
|
||||
== Question 2
|
||||
|
||||
The number $(4^100 mod 6 )^100 mod 10$ equals
|
||||
|
||||
#ans[3]
|
||||
#corr[6 (All's answer)]
|
||||
#ans[2]
|
||||
#ans[None of these]
|
||||
#ans[5]
|
||||
#ans[1]
|
||||
#ans[4]
|
||||
|
||||
== Question 3
|
||||
|
||||
Consider the set of all 99 positive integers not exceeding 99.
|
||||
|
||||
#table(
|
||||
columns: (18%, auto, auto, auto, auto, auto, auto, auto, auto),
|
||||
align: (left, center, center, center, center, center, center, center, center),
|
||||
[],
|
||||
[$binom(99, 50)$],
|
||||
[$2^98$],
|
||||
[$2^97$],
|
||||
[$2^49$],
|
||||
[None of these],
|
||||
[$2^50$],
|
||||
[$binom(99,50) binom(99,49)$],
|
||||
[$binom(99,49) binom(99, 49)$],
|
||||
[How many subsets have an odd number of odd numbers, and an even number of even numbers?],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[How many subsets have an odd number of even numbers and an even number of odd numbers?],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[How many subsets have 49 elements?],
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[How many subsets have an odd number of odd numbers?],
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
== Question 4
|
||||
|
||||
Consider the following system of congruences:
|
||||
|
||||
$
|
||||
x &equiv 1 mod 2 \
|
||||
x &equiv 1 mod 5 \
|
||||
x &equiv 7 mod 9
|
||||
$
|
||||
|
||||
Indicate the set of all solutions to the above system of congruences.
|
||||
|
||||
#ans[None of these]
|
||||
#ans[${90 + 7k | k in ZZ}$]
|
||||
#ans[${1 + 2k | k in ZZ} union {1 + 5k | k in ZZ} union {7 + 9k | k in ZZ}$]
|
||||
#ans[${9 + 90k | k in ZZ}$]
|
||||
#corr[${61 + 90k | k in ZZ}$ (All's answer)]
|
||||
#ans[${7 + 90k | k in ZZ}$]
|
||||
|
||||
|
||||
== Question 5
|
||||
|
||||
Find a greatest common divisor of the polynomials $x^3 - 1$ and $x^3 + 2x^2 + 2x + 1$
|
||||
|
||||
#ans[$x+1$]
|
||||
#ans[$1$(Mikkel's answer)]
|
||||
#ans[$x-1$]
|
||||
#corr[$x^2 + x + 1$]
|
||||
#ans[$x^2 + x - 1$]
|
||||
#ans[None of these]
|
||||
#ans[$x^2 - x + 1$]
|
||||
#ans[$x^2-x-1$]
|
||||
|
||||
|
||||
== Question 6
|
||||
|
||||
Recall that $NN$ is the set of natural numbers, in other words the set of nonnegative integers. For all $n in NN$ define $f(n) = sum^n_(k=0) k dot k! = 0 dot 0! + 1 dot !+ dots + n dot n!$. It is possible to prove by induction that $f(n) = (n+1)! -1$ holds for all nonnegative integers $n$.
|
||||
|
||||
By choosing 4 of the following 8 text fragments and putting them in the correct order, a proof by induction for the above statement can be created.
|
||||
|
||||
A. To prove the induction step, we assume that $f(n+1) = ((n+1)+1)!-1$ holds for some $n in NN$. We will now prove that under this assumption, $f(n) = (n+1)!-1$
|
||||
|
||||
B. To prove the induction step we assume that $f(n) = (n+1)!-1$ holds for all $n in NN$. We will now prove that under this assumption, $f(n+1) = ((n+1)+1)!-1$ holds for all $n in NN$.
|
||||
|
||||
C. To prove the induction step we assume that $f(n) = (n+1)!-1$ holds for some $n in NN$. We will now prove that under this assumption, $f(n+1) = ((n+1)+1)!-1$.
|
||||
|
||||
D. The statement now follows from the principle of mathematical induction.
|
||||
|
||||
E. We prove the statement by induction. The base case is $n = 1$. For $n=1$, we see that $f(1) = sum^1_(k=0)k dot k! = 0 dot 0! + 1 dot 1! = 0 dot 1 + 1 dot 1 = 1$ and also that $(n+1)! -1 = (1+1)!-1 = 2!-1 = 2-1 =1$. This proves the base case.
|
||||
|
||||
F. We prove the statement by induction. The base case is $n=0$. For $n=0$, we see that $f(0) = sum^0_(k=0) k dot k! = 0 dot 0! = 0 dot 1 = 0$ and also that $(n+1)! -1 = (0+1)!-1 = 1!-1 = 1-1 =0$. This proves the base case.
|
||||
|
||||
|
||||
G. We have that $
|
||||
f(n) &= sum^n_(k=0) k dot k! \
|
||||
&= (sum^(n+1)_(k=0) k dot k! ) - (n+1)(n+1)! \
|
||||
&= f(n+1) - (n+1)(n+1)! \
|
||||
&= ((n+1)+1)! - 1 - (n+1)(n+1)! "By the induction hypothesis" \
|
||||
&= (n+2)! -(n+1)(n+1)!-1 \
|
||||
&= (n+2)(n+1)!-(n+1)(n+1)!-1 \
|
||||
&= (n+2 - (n+1))(n+1)!-1 \
|
||||
&= (n+1)! -1
|
||||
$ which is what we wanted to prove. This concludes the induction step.
|
||||
|
||||
H. We have that $
|
||||
f(n+1) &= sum^(n+1)_(k=0) k dot k! \
|
||||
&= (sum^n_(k=0) k dot k!) + (n+1)(n+1)! \
|
||||
&= f(n)+(n+1)(n+1)! \
|
||||
&= (n+1)!-1+(n+1)(n+1)! "By the induction hypothesis" \
|
||||
&= (n+1)(n+1)!+(n+1)!-1 \
|
||||
&= [(n+1)+1](n+1)!-1 \
|
||||
&= (n+2)! - 1 = ((n+1)+1)!-1
|
||||
$ which is what we wanted to prove. This concludes the induction step.
|
||||
|
||||
#table(
|
||||
columns: (35%, 1fr, 1fr,1fr,1fr,1fr,1fr,1fr,1fr),
|
||||
align: (left, center, center, center, center, center, center, center, center),
|
||||
[],
|
||||
[A],
|
||||
[B],
|
||||
[C],
|
||||
[D],
|
||||
[E],
|
||||
[F],
|
||||
[G],
|
||||
[H],
|
||||
[The first fragment is:],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[The second fragment is:],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[The third fragment is:],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
[The fourth fragment is:],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
== Question 7
|
||||
|
||||
For all $n in NN$ define $a_n$ recursively as follows $a_0 = 2, a_1 = 3, a_n = cases(a_(n-1) + n "if" n "is even", a_(n-1) + 2a_(n-2) "if" n "is odd")$
|
||||
|
||||
#corr[37 (All's answer)]
|
||||
#ans[38]
|
||||
#ans[35]
|
||||
#ans[40]
|
||||
#ans[None of these]
|
||||
#ans[36]
|
||||
#ans[39]
|
||||
|
||||
== Question 8
|
||||
|
||||
We wish to construct a bipartite graph with bipartition $(V_1, V_2)$ such that $abs(V_1) = 4, abs(V_2) = 5$ (Note that a bipartite graph has no loops, but it may contain multiple edges.)
|
||||
#table(
|
||||
columns: (40%, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center),
|
||||
[],
|
||||
[The graph exists without multiple edges.],
|
||||
[The graph exists but only if we allow multiple edges.],
|
||||
[The graph does not exist, but it will exist if we are allowed to increase one of the degrees in $V_1$.],
|
||||
[The graph does not exist, but it will exist if we are allowed to increase one of the degrees in $V_2$.],
|
||||
[None of these are correct],
|
||||
[If the degrees in $V_1$ are $5,5,5,5$ and the degrees in $V_2$ are $4,4,4,4,4$ then],
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[If the degrees in $V_1$ are $1,2,2,2$ and the degrees in $V_2$ are $1,2,2,2,2$ then],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[If the degrees in $V_1$ are $4,4,4,4$, and the degrees in $V_2$ are $5,5,5,5,5$ then],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
|
||||
== Question 9
|
||||
|
||||
The formula $binom(m+n, r) = sum^r_(k=a) binom(m, r-k) binom(n,k)$ is true for all integers $m,n,r$ satisfying $0 < m < r < n$ if we let the summation start with:
|
||||
|
||||
#ans[$a = n$]
|
||||
#ans[$a = r$]
|
||||
#ans[None of these]
|
||||
#ans[$a = n -r$]
|
||||
#ans[$a = m$]
|
||||
#corr[$a = r - m$]
|
||||
|
||||
|
||||
== Question 10
|
||||
|
||||
Let $A = {0,1,2,4}, B = {0,1,3,5}, "and" C = {0,2,3,6}$. IF the universal set $U = {0,1,2,3,4,5,6,7}$, then which of the following is equal to $((A inter B) backslash C) union ((B inter C) backslash A) union ((C inter A) backslash B)$
|
||||
|
||||
#ans[${0,1,2,3}$]
|
||||
#ans[All of these sets]
|
||||
#ans[$emptyset$]
|
||||
#ans[${4,5,6}$]
|
||||
#ans[None of these ]
|
||||
#ans[${0,4,5,6}$]
|
||||
#corr[${1,2,3}$]
|
||||
|
||||
== Question 11
|
||||
|
||||
Consider the statement "for every positive rational number $x$ there are positive integers $a$ and $b$ such that $x = a/b$ and $gcd(a,b) = 1$." Which of the following statement in predicate logic is equivalent to this if we let $G(a,b)$ denote the statement " $a "and" b$ are relatively prime"?
|
||||
|
||||
#ans[It is not possible to translate the statement into predicate logic.]
|
||||
#corr[$forall x in QQ^+ exists a in ZZ^+ exists b in ZZ^+ (x = a/b and G(a,b)) $]
|
||||
#ans[$forall x in QQ^+ exists a in ZZ^+ exists b in ZZ^+ (G(a,b) -> x = a/b)$]
|
||||
#ans[$forall x in QQ^+ forall a in ZZ^+ forall b in ZZ^+ (x = a/b and G(a,b))$]
|
||||
#ans[$forall x in QQ^+ exists a in ZZ^+ exists b in ZZ^+ (x = a/b -> G(a,b))$]
|
||||
|
||||
== Question 12
|
||||
|
||||
Given a univerisal set $U$, which of the following is equal to the set $A inter overline((B backslash C))$?
|
||||
|
||||
#ans[None of these]
|
||||
#ans[$A inter B inter overline(C)$]
|
||||
#ans[$(A union B) inter (A union overline(C))$]
|
||||
#corr[$(A inter overline(B)) union (A inter C)$]
|
||||
#ans[$A inter overline(B) inter C$]
|
||||
#ans[$A inter (C backslash B)$]
|
||||
|
||||
|
||||
== Question 13
|
||||
|
||||
The empty set is an element of which of the following sets?
|
||||
|
||||
#ans[${{emptyset}}$]
|
||||
#ans[None of these]
|
||||
#ans[$emptyset$]
|
||||
#ans[${x in RR : x < x}$]
|
||||
#corr[${emptyset}$]
|
||||
#ans[All of these sets]
|
||||
|
||||
== Question 14
|
||||
|
||||
Which of the following are tautologies?
|
||||
|
||||
#ans[$(p -> q) or (not q -> not p)$]
|
||||
#ans[None of these]
|
||||
#ans[$p <-> q$]
|
||||
#ans[All of these]
|
||||
#corr[$(not p or not q) -> (not (p and q))$]
|
||||
#ans[$(p or q or r) and (p or not q or not r)$]
|
||||
|
||||
== Question 15
|
||||
|
||||
Consider all possible seatings of $3n$ people around two tables, one with $n$ seats and one with $2n$ seats. Find the number of seatings when
|
||||
#table(
|
||||
columns: (20%, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center, center, center, center, center),
|
||||
[],
|
||||
[$((3n)!)/(2(n!))$],
|
||||
[$((3n)!)/(4(n!))$],
|
||||
[$((3n)!)/(4n)$],
|
||||
[$2 binom(3n,n)$],
|
||||
[$((3n)!)/(2n^2)$],
|
||||
[$((3n)!)/(4n^2)$],
|
||||
[$((3n)!)/(8n^2)$],
|
||||
[$4 binom(3n,n)$],
|
||||
[None of these],
|
||||
[Two seatings are considered the same when each person has the same left and right neighbor.],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Two seatings are considered the same when each person has the same neighbors (and we do not care about right or left)],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
== Question 16
|
||||
|
||||
For each of the following, determine whether it is surjective/injective, or not a well defined function. Recall that $NN$ is the set of natural numbers, in other words the set of nonnegative integers.
|
||||
|
||||
#table(
|
||||
columns: (35%, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center),
|
||||
[],
|
||||
[Not a well defined function],
|
||||
[Well defined but neither injective nor surjective],
|
||||
[Surjective but not injective],
|
||||
[Injective but not surjective],
|
||||
[Both injective and surjective],
|
||||
[$ f: RR -> ZZ $ given by $f(x) = 2 floor(x/2)$],
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$f : RR -> {x in RR : x >= 0}$ given by $f(x) = sqrt(x^2)$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$f: NN -> NN$ given by $f(x) = 2x +7$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
[$f: NN -> NN$ given by $f(x) = x-x^2$],
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$f: RR -> RR$ given by $f(x) = cases(x "if" x in QQ, -x "if" x in.not QQ)$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
)
|
||||
|
||||
== Question 17
|
||||
|
||||
Consider all permutations of ABCDE
|
||||
#table(
|
||||
columns: (20%, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center, center, center),
|
||||
[],
|
||||
[12],
|
||||
[24],
|
||||
[36],
|
||||
[48],
|
||||
[50],
|
||||
[64],
|
||||
[None of these],
|
||||
[How many contain none of AB, BC, CD],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
[How many contain ACE],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
[How many contain precisely one of AB, CD],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle
|
||||
)
|
||||
|
||||
== Question 18
|
||||
|
||||
For each relation on the set of four distinct elements $a,b,c,d$ below, decide which property it has.
|
||||
|
||||
#table(
|
||||
columns: (30%, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center, center, center),
|
||||
[],
|
||||
[The edges of a hasse diagram],
|
||||
[Partial order],
|
||||
[Total order but not well ordered],
|
||||
[Well-order],
|
||||
[None of these],
|
||||
[Total order but not partial order],
|
||||
[Equivalence relation],
|
||||
[$(a,a),(a,b),(a,c)(a,d)$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$(a,b),(b,c),(c,d)$],
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$(a,a),(b,b),(c,c),\ (d,d),(a,d),(d,a)$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
[$(a,a),(b,b),(c,c),\ (d,d),(d,c)$],
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$(a,a),(b,b),(c,c),(d,d),\ (a,b),(a,c),(a,d),(b,c),\ (b,d),(c,d)$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle
|
||||
)
|
||||
Note: AI'er var uenige om den sidste, så har markeret de to svar jeg fik.
|
||||
|
||||
|
||||
== Question 19
|
||||
|
||||
Which of the following is a recursively defined function for the number of ways to tile an $n times 2$ board using $2 times 1$ tiles.
|
||||
|
||||
#corr[$f(0) = 1, f(1) = 1, f(n) = f(n - 1) + f(n - 2) "for" n >= 2$]
|
||||
#ans[$f(0) = 0, f(1) = 1, f(n) = 2f(n - 2) "for" n >= 2$]
|
||||
#ans[$f(0) = 1, f(1) = 1, f(n) = 2f(n - 2) "for" n >= 2$]
|
||||
#ans[$f(0) = 1, f(1) = 1, f(n) = f(n - 1)f(n - 2) "for" n >= 2$]
|
||||
#ans[All of these]
|
||||
#ans[$f(0) = 0, f(1) = 1, f(n) = f(n - 1) + f(n - 2) "for" n >= 2$]
|
||||
#ans[None of these ]
|
||||
|
||||
|
||||
== Question 20
|
||||
|
||||
Find the coefficient of $x^15 y^20$ in the polynomials below.
|
||||
|
||||
#table(
|
||||
columns: (20%, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center, center, center),
|
||||
[],
|
||||
[$- binom(10,5)2^5$],
|
||||
[$binom(10,5) 2^15$],
|
||||
[$- binom(10,5)2^15$],
|
||||
[0],
|
||||
[None of these],
|
||||
[$-binom(10,5)2^10$],
|
||||
[$- binom(10,3)2^5$],
|
||||
[$(2x^3-y^4)^10$],
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$(1-2x^3y^4)^10$],
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$(x^3-2y^4)^10$],
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
|
||||
== Question 21
|
||||
|
||||
Which of the following is equivalent to the statement " $a$ and $b$ are relatively prime"? The domain for each statement is
|
||||
the set of all positive integers
|
||||
|
||||
#ans[None of these three are equivalent to the statement.]
|
||||
#ans[$not (exists c (c divides a and c divides b and c > 1) )$ is equivalent to the statement, and the other two are not.]
|
||||
#ans[$forall c (not (c divides a) or not (c divides b) or (c <= 1))$ is equivalent to the statement, and the other two are not.]
|
||||
#corr[All of these three are equivalent to the statement.]
|
||||
#ans[$forall c ( (c divides a and c divides b) -> (c <= 1))$ is equivalent to the statement, and other two are not.]
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,780 @@
|
||||
#import "@local/dtu-template:0.5.1":*
|
||||
#import "@preview/cetz:0.4.2"
|
||||
#import "@preview/cetz-venn:0.1.4": venn2, venn3
|
||||
#import "@preview/auto-div:0.1.0": poly-div, poly-div-working
|
||||
|
||||
#definition()[
|
||||
Hej
|
||||
// Small circle for marking answers
|
||||
#let mark-circle = box(width: 0.8em, height: 0.8em, stroke: 0.5pt + black, radius: 50%)
|
||||
|
||||
// Answer option with circle
|
||||
#let ans(body) = grid(columns: (auto, 1fr), column-gutter: 0.5em, align: (center, left), mark-circle, body)
|
||||
|
||||
#let corr-circle = box(width: 0.8em, height: 0.8em, stroke: 0.5pt + black, fill: black, radius: 50%)
|
||||
#let corr(body) = grid(columns: (auto, 1fr), column-gutter: 0.5em, align: (center, left), corr-circle, body)
|
||||
|
||||
#show: dtu-note.with(
|
||||
course: "01017",
|
||||
course-name: "Discrete Mathematics",
|
||||
title: "01019 E24 Exam - Discrete Mathematics",
|
||||
date: datetime.today(),
|
||||
author: "DTU (Technical University of Denmark)",
|
||||
semester: "2025 Fall",
|
||||
)
|
||||
|
||||
#show heading: it => { pagebreak(weak: true); it }
|
||||
|
||||
= 01019 E24 Exam Discrete Mathematics
|
||||
|
||||
Der anvendes en scoringsalgoritme, som er baseret på "One correct answer"
|
||||
|
||||
Dette betyder følgende:
|
||||
- Der er altid præcist ét korrekt svar
|
||||
- Studerende kan kun vælge ét svar per spørgsmål
|
||||
- Hvert rigtigt svar giver 1 point. Så et spørgsmål, der består af f.eks. 3 del-spørgsmål, giver 3 points, hvis alle 3 er korrekte.
|
||||
- Hvert forkert svar giver 0 point (der benyttes IKKE negative point)
|
||||
|
||||
The following approach to scoring responses is implemented and is based on "One correct answer":
|
||||
- There is always only one correct answer
|
||||
- Students are only able to select one answer per question
|
||||
- Every correct answer that you click on corresponds to 1 point, so a question with 3 parts is worth 3 points if you get every part correct.
|
||||
- Every incorrect answer corresponds to 0 points (incorrect answers do not result in subtraction of points)
|
||||
|
||||
== Question 1
|
||||
If $a, b, c$, and $d$ are positive integers such that $a b | c d$, then which of the following must be true?
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[$a|"lcm"(c, d)$ or $b|"lcm"(c, d)$]
|
||||
#corr[If $p$ is a prime that divides $a$, then $p|c$ or $p|d$]
|
||||
#ans[None of these]
|
||||
#ans[If $b$ is prime, then $b|"gcd"(c, d)$]
|
||||
#ans[$"gcd"(a, b)| "gcd"(c, d)$]
|
||||
#ans[$a|c$ or $a|d$ or $b|c$ or $b|d$]
|
||||
|
||||
#solution()[
|
||||
Because if you instead of $a,b,c,d$ put them factorized into primes. Then if $a b$ divides $c d$ they must share some common primes when factorized, and thus if $p$ divides $a$ so it is in the factorized $a b$, then it must also be in the factorized $c d$ and thus $p | c$ or $p | d$
|
||||
]
|
||||
|
||||
== Question 2
|
||||
For $n >= 4$, the number of edges in the $n$-cube $Q_n$ is
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[None of these]
|
||||
#ans[$2^n + 16$]
|
||||
#corr[$n 2^(n-1)$]
|
||||
#ans[$2^(n+1)$]
|
||||
#ans[$n! + 8$]
|
||||
|
||||
#solution()[
|
||||
It it probably not the 2nd or last one. 3rd one makes more intuitive sense than 4th one.
|
||||
]
|
||||
|
||||
== Question 3
|
||||
For each of the following, determine whether it is surjective/injective, or not a well defined function. Recall that $NN$ is the set of natural numbers, in other words the set of nonnegative integers, and $ZZ^+$ is the set of positive integers.
|
||||
|
||||
*Vælg de rigtige svarmuligheder*
|
||||
|
||||
#table(
|
||||
columns: (40%, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[],
|
||||
[Not well defined],
|
||||
[Well defined but neither],
|
||||
[Surjective but not injective],
|
||||
[Injective but not surjective],
|
||||
[Both surjective and injective],
|
||||
[$f: ZZ^+ -> NN$ given by $f(x) = floor(log_2(x))$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$f: RR -> ZZ^+$ given by $f(x) = floor(|x|)$],
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$f: NN -> ZZ$ given by $f(x) = cases(ceil(x\/2) "if" x "is even", -ceil(x\/2) "if" x "is odd")$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
[$f: RR -> {-1, 0, 1}$ given by $f(x) = floor(x) - ceil(x)$],
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$f: NN -> NN$ given by $f(x) = x^3 + 1$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
#solution()[
|
||||
/ 1):
|
||||
It is not injective because when rounded down, multiple x-values will give the same y-value. It is surjective since it continues on forever.
|
||||
|
||||
/ 2):
|
||||
$0, 0.5, 0.6$, etc. are in $RR$, but rounded down to $0$ are not in $ZZ^+$ so this function isn't well defined.
|
||||
|
||||
/ 3):
|
||||
You have all odd numbers halved and rounded up make up the negative numbers, and same with even numbers. Since every integer times 2 is also an integer, every number in $ZZ$ will have a corresponding x-value because of that. Also since integers times two only have one answer, you will not have multiple numbers in $NN$ give the same value
|
||||
|
||||
/ 4):
|
||||
This is not injective because almost all x-values will give the same y-value (-1). It is not surjective because a positive number rounded down minus same number rounded up will give -1. And same for negative numbers.
|
||||
|
||||
/ 5):
|
||||
No two natural numbers cubed plus one will give the same value, so this is injective. But there are a lot of natural numbers that is not hit.
|
||||
]
|
||||
|
||||
== Question 4
|
||||
Consider the following three statements on the complete graph $K_(2n)$:
|
||||
|
||||
(a): $K_(2n)$ has $binom(2n, 2)$ edges
|
||||
|
||||
(b): $K_(2n)$ has $2binom(n, 2) + n^2$ edges
|
||||
|
||||
(c): $K_(2n)$ has $n(2n - 1)$ edges
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[(a) and (b) are true, but (c) is false]
|
||||
#corr[(a) and (b) and (c) are all true]
|
||||
#ans[(a) and (c) are true, but (b) is false]
|
||||
#ans[(b) and (c) are true, but (a) is false]
|
||||
#ans[Precisely one of (a),(b),(c) is true]
|
||||
|
||||
#solution()[
|
||||
/ *(a)*: A complete graph is a graph where all vertices are connected, but only once. So the amount of edges can also be described as how many ways can you select two of $2n$ elements (how many ways can you select to vertices to connect in the graph)
|
||||
|
||||
/ *(b)*: This can be verified using (a). Take $n=10$ for example:
|
||||
$
|
||||
vec(20,2) = 190\
|
||||
2 vec(10,2) + 100 = 2 dot 45 + 100 = 190
|
||||
$
|
||||
This holds true, so (b) must be true as well.
|
||||
|
||||
/ *(c)*: We can check this as well. For $n=10$:
|
||||
$
|
||||
190 = 10*19
|
||||
$
|
||||
This holds true as well.
|
||||
|
||||
]
|
||||
|
||||
== Question 5
|
||||
Consider a simple graph with degrees 2,2,3,3,3,3,3.
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[Such a graph exists, and any such graph has less than 19 edges]
|
||||
#corr[Such a graph does not exist]
|
||||
#ans[Such a graph exists, and any such graph has precisely 19 edges]
|
||||
#ans[Such a graph exists, and any such graph has more than 19 edges]
|
||||
#ans[There exists such a graph with more than 19 edges and another with less than 19 edges]
|
||||
|
||||
#solution()[
|
||||
Uneven amount of odd degrees, so it cannot exist.
|
||||
]
|
||||
|
||||
== Question 6
|
||||
How many elements are in the union of four sets if each set has 200 elements, each pair of sets share 50 elements, each three of the sets share 25 elements, and there are 5 elements in all four sets.
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[395]
|
||||
#ans[695]
|
||||
#ans[495]
|
||||
#corr[595]
|
||||
#ans[None of these]
|
||||
|
||||
#solution()[
|
||||
Imagine the sets $A,B,C,D$:
|
||||
$
|
||||
A + B + C + D - |A inter B| - |A inter C| - |A inter D| - |B inter C| - |B inter D| - |C inter D|\
|
||||
+ |A inter B inter C| + |B inter C inter D| + |C inter D inter A| + |D inter A inter B|\
|
||||
- |A inter B inter C inter D| = \
|
||||
200+200+200+200 - 50-50-50-50-50-50\
|
||||
+25+25+25+25-5 = 595
|
||||
$
|
||||
]
|
||||
|
||||
== Question 7
|
||||
Suppose that $a, b, c$, and $m$ are positive integers such that $a c equiv b c mod m$. Which of the following must be true?
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[$a equiv b mod m$]
|
||||
#corr[$a - b in {k m : k in ZZ}$ if $"gcd"(c, m) = 1$]
|
||||
#ans[$c|m(a - b)$]
|
||||
#ans[$a equiv b mod c m$]
|
||||
#ans[None of these]
|
||||
|
||||
#solution()[
|
||||
The solution means $a equiv b mod m$ but only if $c,m$ are coprime. This is because $a c equiv b c mod m$ cant also be written as $m | c(a-b)$, so for our equation to hold, $m$ must divide $a-b$ not $c$, so $gcd(c,m)=1$
|
||||
]
|
||||
|
||||
== Question 8
|
||||
If $2a + 3 equiv 2b + 3 mod m$, for positive integers $a, b$, and $m$, then which of the following does NOT necessarily have to be true?
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[$2a equiv 2b mod m$]
|
||||
#corr[$a = k m + b$ for some $k in ZZ$]
|
||||
#ans[$14a equiv 14b + 7m mod m$]
|
||||
#ans[All of these are true]
|
||||
#ans[$m|2(a - b)$]
|
||||
|
||||
#solution()[
|
||||
Because for example: $a=101, b=100, m = 2$
|
||||
|
||||
$
|
||||
205 equiv 203 mod 2\
|
||||
101 != 2k + 100 "for some" k in ZZ
|
||||
$
|
||||
]
|
||||
|
||||
== Question 9
|
||||
Which of these three are partitions of $ZZ times ZZ$, that is, the set of ordered pairs of integers:
|
||||
|
||||
(a): the set of pairs $(x, y)$ where $x$ or $y$ (or both) are odd; the set of pairs $(x, y)$ where $x$ and $y$ are even;
|
||||
|
||||
(b): the set of pairs $(x, y)$ where $x$ and $y$ are odd; the set of pairs $(x, y)$ where $x$ and $y$ are even;
|
||||
|
||||
(c): the set of pairs $(x, y)$ where $x$ or $y$ (or both) are odd; the set of pairs $(x, y)$ where $x$ or $y$ (or both) are even.
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[None of them are]
|
||||
#corr[(a) is a partition but (b),(c) are not]
|
||||
#ans[Precisely two of them are]
|
||||
#ans[(b) is a partition but (a),(c) are not]
|
||||
#ans[(c) is a partition but (a),(b) are not]
|
||||
|
||||
#solution()[
|
||||
To be a partition, the following conditions must be met:
|
||||
+ Every element $a in S$ belongs to exactly one equivalence class $[a]_tilde$.
|
||||
+ The equivalence classes are pairwise disjoint: if $[a]_tilde eq.not [b]_tilde$, then $[a]_tilde inter [b]_tilde = emptyset$.
|
||||
+ The union of all equivalence classes equals $S$.
|
||||
|
||||
So basically you can't have pairs appear more than once, and the union of all the pairs must be equal to, here, $ZZ$.
|
||||
|
||||
/ a): This satisfies all three.
|
||||
/ b): This satisfies the first two, but not the third.
|
||||
/ c): This doesn't satisfy the first one.
|
||||
]
|
||||
|
||||
== Question 10
|
||||
Consider the statement: There exist infinitely many simple graphs (that is, graphs with no loops and no multiple edges) such that all degrees are distinct. This statement can be proved to be
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[neither true nor false because some graphs have all degrees distinct and others do not]
|
||||
#corr[false by the pigeonhole principle]
|
||||
#ans[false by giving a counterexample]
|
||||
#ans[true by the pigeonhole principle]
|
||||
#ans[true by induction]
|
||||
|
||||
#solution()[
|
||||
If you have a graph of $n$ vertices, and then add another one. It will need to have $n+1$ edges, but for that to be true, it would have to connect to itself, which it can't (and for example the first edge, would need to connect to it as well).
|
||||
|
||||
In terms of Pigeonhole principle, we will end up having too many edges.
|
||||
]
|
||||
== Question 11
|
||||
Consider the polynomial $(2x^2 - 3y^3)^8$.
|
||||
|
||||
*Vælg de rigtige svarmuligheder*
|
||||
|
||||
#table(
|
||||
columns: (1fr, auto, auto, auto, auto, auto),
|
||||
align: (left, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[ ],
|
||||
[0],
|
||||
[$2^4 3^4 binom(8, 4)$],
|
||||
[$-2^4 3^4 binom(8, 4)$],
|
||||
[$2^3 3^6 binom(8, 4)$],
|
||||
[$-2^4 3^6 binom(8, 4)$],
|
||||
[The coefficient of $x^8 y^12$ is],
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[The coefficient of $x^6 y^9$ is],
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
#solution()[
|
||||
You can use calculator to calculate this. But by intuition:
|
||||
|
||||
You know that $(x+y)^n$ will have coefficient: $binom(n,k)x^(n-k)y^k$
|
||||
|
||||
For $x^8y^12$:
|
||||
|
||||
Here we have $n=8, k = 8-8/2=4$. So coefficients are: $2^(n-k=4)3^(k=4) binom(n=8,k=4)$. It will be positive as we multiple a negative number even number of times, so its positive.
|
||||
|
||||
For $x^6y^9$. Here we have $n=8, k = 8-6/2=5$ but $3 dot 5 != 9$ so this doesnt exist.
|
||||
]
|
||||
|
||||
== Question 12
|
||||
The polynomial $x^n + 1$ is divisible by the polynomial $x + 1$ (where $n$ is a positive integer)
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[for each $n >= 1$]
|
||||
#corr[for each odd $n >= 1$, and for no even $n$]
|
||||
#ans[for each even $n >= 4$, and for no odd $n$]
|
||||
#ans[for infinitely many, but not all, even $n$, and for no odd $n$]
|
||||
#ans[for $n = 1$ only]
|
||||
|
||||
#solution()[
|
||||
Use calculator to solve this.
|
||||
]
|
||||
|
||||
== Question 13
|
||||
The least number of cables required to connect ten computers to five printers to guarantee that, for every choice of five of the ten computers, these five computers can directly access five different printers is
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[40]
|
||||
#ans[None of these]
|
||||
#ans[$binom(10, 5)$]
|
||||
#corr[30]
|
||||
#ans[50]
|
||||
|
||||
#solution()[
|
||||
To guarantee that no matter the five computers we select they will connect to different printers, each printer must be connected to >5 computers so 6. And since there's 5 printers, its: $5 dot 6 =30$
|
||||
]
|
||||
|
||||
== Question 14
|
||||
Consider the following relations on ${1, 2, 3, 4, 5, 6}$:
|
||||
|
||||
$R_1$: ${(1, 2),(2, 3),(1, 3),(4, 5),(5, 6),(4, 6)}$.
|
||||
|
||||
$R_2$: ${(1, 1),(2, 2),(3, 3),(4, 4),(5, 5),(6, 6),(1, 2),(3, 4),(5, 6),(1, 6)}$.
|
||||
|
||||
$R_3$: ${(1, 2),(2, 3),(3, 4),(4, 5),(5, 6),(1, 3),(2, 4),(3, 5),(4, 6)}$.
|
||||
|
||||
Recall that questions below may appear in random order.
|
||||
|
||||
*Vælg de rigtige svarmuligheder*
|
||||
|
||||
#table(
|
||||
columns: (15%, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[ ],
|
||||
[an \ equivalence relation],
|
||||
[a partial \ ordering],
|
||||
[transitive and reflexive\ but not \ antisymmetric],
|
||||
[transitive and antisymmetric but not\ reflexive],
|
||||
[none of these],
|
||||
[$R_3$ is],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
[$R_2$ is],
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$R_1$ is],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
#solution()[
|
||||
Definitions:
|
||||
+ *Reflexive:* $forall a in S, a R a$
|
||||
+ *Symmetric:* $forall a, b in S$, if $a R b$ then $b R a$
|
||||
+ *Antisymmetric:* $forall a, b in S$, if $a R b$ and $b R a$ then $a = b$
|
||||
+ *Transitive:* $forall a, b, c in S$, if $a R b$ and $b R c$ then $a R c$
|
||||
|
||||
A partial ordering is Reflexive, Antisymmetric and Transitive.
|
||||
|
||||
An equivalence relation is Reflexive, Symmetric and Transitive
|
||||
|
||||
/ $R_3$: Not reflexive, not symmetric, is antisymmetric and not transitive (you have $(1,2), (2,4)$ but not $(1,4)$)
|
||||
|
||||
/ $R_2$: It is reflexive, antisymmetric and transitive. Thus, a partial ordering
|
||||
|
||||
/ $R_1$: Not reflexive, not symmetric, is antisymmetric, is transitive.
|
||||
]
|
||||
|
||||
== Question 15
|
||||
For each of the following values of $n$, determine the multiplicative inverse of $n mod 9$ or indicate that it does not exist.
|
||||
|
||||
*Vælg de rigtige svarmuligheder*
|
||||
|
||||
#table(
|
||||
columns: (auto, auto, auto, auto, auto, auto, auto, auto, auto),
|
||||
align: (left, center, center, center, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[ ],
|
||||
[*Does not exist*],
|
||||
[*0*],
|
||||
[*1*],
|
||||
[*2*],
|
||||
[*3*],
|
||||
[*4*],
|
||||
[*5*],
|
||||
[*6*],
|
||||
[$n = 6$],
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$n = 2$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
[$n = 7$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
#solution()[
|
||||
The multiplicative inverse is the number for which you need to multiply n for $n dot x equiv 1 mod 9$ here.
|
||||
|
||||
This can be calculated in Sympy.
|
||||
|
||||
/ $n=6$: No value
|
||||
|
||||
/ $n=2$: $2 dot 5=10 equiv 1 mod 9$
|
||||
|
||||
/ $n=7$: $7 dot 4 = 28 equiv 1 mod 9$
|
||||
]
|
||||
|
||||
== Question 16
|
||||
Given a universal set $U$, which of the following sets are necessarily equal to $(overline(B) - A) union (overline(C) - A)$?
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[$emptyset$]
|
||||
#ans[$overline((B union C)) - A$]
|
||||
#ans[$((U - B) union (U - C)) inter A$]
|
||||
#corr[$overline((B inter C))- A$]
|
||||
#ans[None of these]
|
||||
|
||||
#solution()[
|
||||
The given equation mean: What is in either not $B$ nor $A$, or not in $C$ nor $A$.
|
||||
|
||||
This can be rewritten as what is not in both $B$ and $C$ and also not in $A$
|
||||
]
|
||||
== Question 17
|
||||
20 people are seated around a round table.
|
||||
|
||||
*Vælg de rigtige svarmuligheder*
|
||||
|
||||
#table(
|
||||
columns: (1fr, auto, auto, auto, auto, auto),
|
||||
align: (left, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[ ],
|
||||
[$2^20$],
|
||||
[$2^19$],
|
||||
[$20!$],
|
||||
[$19!$],
|
||||
[$19!\/2$],
|
||||
[Two seatings are considered identical if each person has the same two neighbors in the two seatings (but we don't care about left and right). The number of seatings is],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
[Two seatings are considered identical if each person has the same left neighbor and the same right neighbor in the two seatings. The number of seatings is],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
[Two seatings are considered identical if each person has the same left neighbor in the two seatings. The number of seatings is],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
#solution()[
|
||||
Can be calculated in Sympy!
|
||||
|
||||
But intuitively:
|
||||
|
||||
/ a): Here we have $20!/(20*2)=19!/2$. Because for every seating you have, you can rotate it 20 times and same neighbors, and you can mirror it, and same neighbors.
|
||||
|
||||
/ b): Same as before but only rotation now so: $20!/20=19!$
|
||||
|
||||
/ c): This is the same as before as if you change a persons right neighbor, the now have a new left neighbor so you cant do that.
|
||||
]
|
||||
|
||||
== Question 18
|
||||
Let $a$ and $b$ be positive integers. Which of the following integers can NOT necessarily be written as $a s + b t$ for some integers $s$ and $t$?
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[All of these can be written as $a s + b t$ for some integers $s$ and $t$]
|
||||
#ans[$"gcd"(a, b)^2 - 17 "lcm"(a, b)$]
|
||||
#corr[$("lcm"(a,b))/("gcd"(a,b))$]
|
||||
#ans[$"gcd"(2a, 6b)$]
|
||||
#ans[$"gcd"(a, b)$]
|
||||
|
||||
#solution()[
|
||||
$"lcm"(a,b)$ is the least common multiple of $a,b$ so that means if you go any lower than that, it can't necessarily be divided by $a,b$ so you cant necessarily write it as $a s + b t$
|
||||
]
|
||||
|
||||
== Question 19
|
||||
Which of the following gives a recursive definition of the number of ways to choose 3 elements from an $n$ element set for $n >= 3$?
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[$f(3) = 1$ and $f(n + 1) = binom(n, 2)f(n - 1)$ for $n >= 3$]
|
||||
#ans[None of these]
|
||||
#ans[$f(4) = 1$ and $f(n) = n^4 + f(n - 1)$ for $n > 4$]
|
||||
#ans[$f(3) = 1$ and $f(n) = binom(n, 3) + f(n - 1)$ for $n > 3$]
|
||||
#ans[$f(n) = n^3$]
|
||||
#corr[$f(3) = 1$ and $f(n) = ((n-1)(n-2))/2 + f(n - 1)$ for $n > 3$]
|
||||
|
||||
== Question 20
|
||||
For any integers $n, m$, where $2 <= n <= m$, the binomial coefficient $binom(n+m, m+2)$ equals
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[$sum_(k=0)^n binom(n, k)binom(m, m-k)$]
|
||||
#corr[$sum_(k=2)^n binom(n, k)binom(m, m+2-k)$]
|
||||
#ans[$sum_(k=0)^(n+2) binom(n, k)binom(m, n-k)$]
|
||||
#ans[None of these because we cannot use Vandermonde's identity in this case]
|
||||
#ans[$sum_(k=1)^n binom(n, k)binom(m, m+1-k)$]
|
||||
|
||||
#solution()[
|
||||
Because we know: $mat(m+n;r)=sum^r_(k=0) mat(n;k) mat(m;r-k)$
|
||||
]
|
||||
|
||||
== Question 21
|
||||
The number of derangements of 1,2,3,4,5,6,7 ending with 1,2,3 in some order is
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[$3!(4! - 1)$]
|
||||
#ans[$3!4!\/2$]
|
||||
#ans[$3!4!$]
|
||||
#corr[$3!(4! - 3!)$]
|
||||
#ans[None of these]
|
||||
|
||||
#solution()[
|
||||
Can be calculated in Sympy.
|
||||
|
||||
Intuitively:
|
||||
|
||||
There are $3!$ ways to order $1,2,3$. And if it must end in that, there are 4 more numbers to order, which have $4!$ numbers of ways to be ordered. Since it is a derangement though, this means that no number can have its original position, so we must count out the positions where 4 is in the 4th spot, so $- 3!$. So it becomes $3! (4!-3!)$
|
||||
]
|
||||
|
||||
== Question 22
|
||||
Consider the following system of congruences:
|
||||
|
||||
$x equiv 1 mod 2$
|
||||
|
||||
$x equiv 4 mod 5$
|
||||
|
||||
$x equiv 3 mod 7$
|
||||
|
||||
Indicate the set of all solutions to the above system of congruences.
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[${12 + 70k | k in ZZ}$]
|
||||
#ans[${8 + 70k | k in ZZ}$]
|
||||
#ans[${1 + 2k | k in ZZ} union {4 + 5k | k in ZZ} union {3 + 7k | k in ZZ}$]
|
||||
#ans[${70 + 12k | k in ZZ}$]
|
||||
#ans[${8 + 14k | k in ZZ}$]
|
||||
#corr[${59 + 70k | k in ZZ}$]
|
||||
#ans[None of these]
|
||||
|
||||
#solution()[
|
||||
Can be solved using Sympy.
|
||||
|
||||
Also calculate for each of the formulas whether 2 divides it minus 1, 5 divides it minus 4 and 7 divides it minus 3.
|
||||
]
|
||||
|
||||
== Question 23
|
||||
It is possible to prove that a simple graph on $n >= 1$ vertices has at most $binom(n, 2)$ edges using mathematical induction. Here we take $binom(1, 2)$ to be equal to zero.
|
||||
|
||||
By choosing some of the following text fragments and putting them in the correct order, a proof by induction for the above statement can be created.
|
||||
|
||||
*A)* To prove the inductive step, assume that every simple graph on $n$ vertices has at most $binom(n, 2)$ edges, for every integer $n >= 1$. We will show that this implies that every simple graph on $n + 1$ vertices has at most $binom(n+1, 2)$ edges.
|
||||
|
||||
*B)* To prove the inductive step, assume that every simple graph on $n$ vertices has at most $binom(n, 2)$ edges, for some fixed integer $n >= 1$. We will show that this implies that every simple graph on $n + 1$ vertices has at most $binom(n+1, 2)$ edges.
|
||||
|
||||
*C)* The statement now follows from the principle of mathematical induction.
|
||||
|
||||
*D)* Since $v$ had at most $n$ edges incident to it, we have that $G$ has at most $n + binom(n, 2)$ edges. Moreover, $n + binom(n, 2) = n + (n(n-1))/2 = 1/2(2n + n^2 - n) = 1/2(n^2 + n) = ((n+1)n)/2 = binom(n+1, 2)$.
|
||||
|
||||
*E)* We prove the statement by induction. The base case is $n = 1$. A simple graph on 1 vertex cannot have any edges, so it has at most $binom(1, 2) = 0$ edges.
|
||||
|
||||
*F)* Let $G$ be a simple graph on $n + 1$ vertices. Pick any vertex $v in V(G)$ and note that $v$ has at most $n$ edges incident to it since there are $n$ vertices it could be adjacent to. Let $G'$ be the graph obtained from $G$ by removing $v$ and all the edges incident to $v$. Then $G'$ is a simple graph on $n$ vertices and thus it has at most $binom(n, 2)$ edges by our induction hypothesis.
|
||||
|
||||
*G)* Let $G$ be a simple graph on $n$ vertices. Construct a simple graph $G'$ on $n + 1$ vertices by adding a new vertex $v$ to $G$ and making it adjacent to an arbitrary subset $S$ of vertices of $G$. Since $G$ has $n$ vertices, we have that $|S| <= n$ and so $v$ is incident to at most $n$ edges. Therefore $G'$ has at most $n + binom(n, 2) = n + (n(n-1))/2 = 1/2(2n + n^2 - n) = 1/2(n^2 + n) = ((n+1)n)/2 = binom(n+1, 2)$ edges.
|
||||
|
||||
*PLEASE NOTE THAT THE QUESTIONS AND ANSWERS BELOW APPEAR IN RANDOM ORDER. PLEASE READ THEM CAREFULLY.*
|
||||
|
||||
*Vælg de rigtige svarmuligheder*
|
||||
|
||||
#block(width: 100%, breakable: false)[
|
||||
#table(
|
||||
columns: (20%, 0.5fr, 0.5fr, 0.5fr, 0.5fr, 0.5fr, 0.5fr, 0.5fr, 1fr),
|
||||
align: (left, center, center, center, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[ ],
|
||||
[*A*],
|
||||
[*B*],
|
||||
[*C*],
|
||||
[*D*],
|
||||
[*E*],
|
||||
[*F*],
|
||||
[*G*],
|
||||
[*No more \ fragments*],
|
||||
[The first text fragment of the proof is],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[The second text fragment of the proof is],
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[The third text fragment of the proof is],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[The fourth text fragment of the proof is],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[The fifth text fragment of the proof is],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
]
|
||||
|
||||
#solution()[
|
||||
First is *E)* because it is our base step.
|
||||
|
||||
Then it is *B)* for the start of the inductive step. It is not *A)* because we calculate induction for some _fixed_ integer, not every integer.
|
||||
|
||||
Then is *F)* because it makes more sense than *G)*
|
||||
|
||||
Then is *D)* because calculations
|
||||
|
||||
Then is *C)* because there is another option left and this also concludes stuff.
|
||||
]
|
||||
|
||||
== Question 24
|
||||
Let $P(x)$ denote the statement "$x$ is prime". Which of the following statements can be written in predicate logic as the following:
|
||||
|
||||
$forall x in ZZ (x > 1 -> (exists y in NN (P(y) and x < y < 2x)))$
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[For every integer $x$ greater than 1, every number strictly between $x$ and $2x$ is prime.]
|
||||
#ans[None of these]
|
||||
#ans[For every integer $x$, either $x > 1$ or there is a prime $y$ such that $x < y < 2x$.]
|
||||
#ans[For any integer $x > 1$ and any prime $y$, if $x > 1$ then $x < y < 2x$.]
|
||||
#corr[For every integer $x > 1$, there is a prime $y$ such that $x < y < 2x$.]
|
||||
#ans[There exist infinitely many primes.]
|
||||
|
||||
#solution()[
|
||||
This is just using words to describe the statement
|
||||
]
|
||||
|
||||
== Question 25
|
||||
Let $a$ and $b$ be two positive integers with $a b = 5292 = 2^2 3^3 7^2$. Which of the following values CANNOT be the greatest common divisor of $a$ and $b$?
|
||||
|
||||
*Vælg en svarmulighed*
|
||||
#ans[1]
|
||||
#ans[3]
|
||||
#corr[36]
|
||||
#ans[42]
|
||||
#ans[All of these are possible values for $"gcd"(a, b)$]
|
||||
|
||||
#solution()[
|
||||
36 can't be gcd because, even though you can construct it using the primes, you do: $2 dot 2 dot 3 dot 3$, and then you wouldn't be able to construct it again, meaning it would only be able to divide one of $a,b$
|
||||
]
|
||||
|
||||
== Question 26
|
||||
Consider the number of ways we can put $n + 1$ distinguishable balls (meaning that we can tell the difference between them) into $n$ distinct boxes.
|
||||
|
||||
*Vælg de rigtige svarmuligheder*
|
||||
|
||||
#table(
|
||||
columns: (1fr, auto, auto, auto, auto, auto),
|
||||
align: (left, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[ ],
|
||||
[*none of these*],
|
||||
[$2n!$],
|
||||
[$binom(n+1, 2)n!$],
|
||||
[$n^(n+1) - 2n!$],
|
||||
[$n^(n+1) - binom(n+1, 2)n!$],
|
||||
[If at least one box is empty, the number of ways is],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
[If no box is empty, the number of ways is],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
#solution()[
|
||||
For the non-empty one first:
|
||||
|
||||
You first chose 2 of the $n+1$ balls, these will go into the same container. Then you put the balls into the container (the two balls just acting as one)
|
||||
|
||||
For the non-empty one:
|
||||
|
||||
You can arrange the balls in $n$ ways in the boxes, but then you must subtract all the ways to order the balls when there are no empty boxes as there must be at least one empty box.
|
||||
]
|
||||
|
||||
21477
Diskret Mat/Gamle eksamener/Exam cheatsheat.pdf
Normal file
21477
Diskret Mat/Gamle eksamener/Exam cheatsheat.pdf
Normal file
File diff suppressed because one or more lines are too long
1415
Diskret Mat/Gamle eksamener/Exam cheatsheat.typ
Normal file
1415
Diskret Mat/Gamle eksamener/Exam cheatsheat.typ
Normal file
File diff suppressed because it is too large
Load Diff
12431
Diskret Mat/Gamle eksamener/Untitled-.pdf
Normal file
12431
Diskret Mat/Gamle eksamener/Untitled-.pdf
Normal file
File diff suppressed because it is too large
Load Diff
577
Diskret Mat/Gamle eksamener/Untitled-.typ
Normal file
577
Diskret Mat/Gamle eksamener/Untitled-.typ
Normal file
@@ -0,0 +1,577 @@
|
||||
#import "@local/dtu-template:0.5.1":*
|
||||
#import "@preview/cetz:0.4.2"
|
||||
#import "@preview/cetz-venn:0.1.4": venn2, venn3
|
||||
#import "@preview/auto-div:0.1.0": poly-div, poly-div-working
|
||||
|
||||
#let mark-circle = box(width: 0.8em, height: 0.8em, stroke: 0.5pt + black, radius: 50%)
|
||||
#let ans(body) = grid(columns: (auto, 1fr), column-gutter: 0.5em, align: (center, left), mark-circle, body)
|
||||
|
||||
#let corr-circle = box(width: 0.8em, height: 0.8em, stroke: 0.5pt + black, fill: black, radius: 50%)
|
||||
#let corr(body) = grid(columns: (auto, 1fr), column-gutter: 0.5em, align: (center, left), corr-circle, body)
|
||||
|
||||
#show heading: it => { pagebreak(weak: true); it }
|
||||
== Question 1
|
||||
|
||||
If $p,q$ are prime numbers such that $100 < p < q$, then the number of positive integers less than $p q$ which are relative prime to $p q$ is:
|
||||
|
||||
#corr[$p q - p - q + 1$ (Rasmus's, Sebastian's answer)]
|
||||
#ans[$p q - q + 1$]
|
||||
#ans[$p q-p-q-1$]
|
||||
#ans[$p q-p-q$ (Mikkel's answer)]
|
||||
#ans[$p q-1$]
|
||||
#ans[None of these]
|
||||
|
||||
== Question 2
|
||||
|
||||
The number $(4^100 mod 6 )^100 mod 10$ equals
|
||||
|
||||
#ans[3]
|
||||
#corr[6 (All's answer)]
|
||||
#ans[2]
|
||||
#ans[None of these]
|
||||
#ans[5]
|
||||
#ans[1]
|
||||
#ans[4]
|
||||
|
||||
== Question 3
|
||||
|
||||
Consider the set of all 99 positive integers not exceeding 99.
|
||||
|
||||
#table(
|
||||
columns: (18%, auto, auto, auto, auto, auto, auto, auto, auto),
|
||||
align: (left, center, center, center, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[],
|
||||
[$binom(99, 50)$],
|
||||
[$2^98$],
|
||||
[$2^97$],
|
||||
[$2^49$],
|
||||
[None of these],
|
||||
[$2^50$],
|
||||
[$binom(99,50) binom(99,49)$],
|
||||
[$binom(99,49) binom(99, 49)$],
|
||||
[How many subsets have an odd number of odd numbers, and an even number of even numbers?],
|
||||
mark-circle,
|
||||
[Mikkel's answer],
|
||||
[*Sebastian's answer*],
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[How many subsets have an odd number of even numbers and an even number of odd numbers?],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
corr-circle,
|
||||
[Rasmus's answer],
|
||||
[Sebastian's answer],
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[How many subsets have 49 elements?],
|
||||
[*Rasmus's answer*],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's, Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[How many subsets have an odd number of odd numbers?],
|
||||
mark-circle,
|
||||
[*Rasmus's, Sebastian's answer*],
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
== Question 4
|
||||
|
||||
Consider the following system of congruences:
|
||||
|
||||
$
|
||||
x &equiv 1 mod 2 \
|
||||
x &equiv 1 mod 5 \
|
||||
x &equiv 7 mod 9
|
||||
$
|
||||
|
||||
Indicate the set of all solutions to the above system of congruences.
|
||||
|
||||
#ans[None of these]
|
||||
#ans[${90 + 7k | k in ZZ}$]
|
||||
#ans[${1 + 2k | k in ZZ} union {1 + 5k | k in ZZ} union {7 + 9k | k in ZZ}$]
|
||||
#ans[${9 + 90k | k in ZZ}$]
|
||||
#corr[${61 + 90k | k in ZZ}$ (All's answer)]
|
||||
#ans[${7 + 90k | k in ZZ}$]
|
||||
|
||||
|
||||
== Question 5
|
||||
|
||||
Find a greatest common divisor of the polynomials $x^3 - 1$ and $x^3 + 2x^2 + 2x + 1$
|
||||
|
||||
#ans[$x+1$]
|
||||
#ans[$1$(Mikkel's answer)]
|
||||
#ans[$x-1$]
|
||||
#corr[$x^2 + x + 1$ (Rasmus's, Sebastian's answer)]
|
||||
#ans[$x^2 + x - 1$]
|
||||
#ans[None of these]
|
||||
#ans[$x^2 - x + 1$]
|
||||
#ans[$x^2-x-1$]
|
||||
|
||||
|
||||
== Question 6
|
||||
|
||||
Recall that $NN$ is the set of natural numbers, in other words the set of nonnegative integers. For all $n in NN$ define $f(n) = sum^n_(k=0) k dot k! = 0 dot 0! + 1 dot !+ dots + n dot n!$. It is possible to prove by induction that $f(n) = (n+1)! -1$ holds for all nonnegative integers $n$.
|
||||
|
||||
By choosing 4 of the following 8 text fragments and putting them in the correct order, a proof by induction for the above statement can be created.
|
||||
|
||||
A. To prove the induction step, we assume that $f(n+1) = ((n+1)+1)!-1$ holds for some $n in NN$. We will now prove that under this assumption, $f(n) = (n+1)!-1$
|
||||
|
||||
B. To prove the induction step we assume that $f(n) = (n+1)!-1$ holds for all $n in NN$. We will now prove that under this assumption, $f(n+1) = ((n+1)+1)!-1$ holds for all $n in NN$.
|
||||
|
||||
C. To prove the induction step we assume that $f(n) = (n+1)!-1$ holds for some $n in NN$. We will now prove that under this assumption, $f(n+1) = ((n+1)+1)!-1$.
|
||||
|
||||
D. The statement now follows from the principle of mathematical induction.
|
||||
|
||||
E. We prove the statement by induction. The base case is $n = 1$. For $n=1$, we see that $f(1) = sum^1_(k=0)k dot k! = 0 dot 0! + 1 dot 1! = 0 dot 1 + 1 dot 1 = 1$ and also that $(n+1)! -1 = (1+1)!-1 = 2!-1 = 2-1 =1$. This proves the base case.
|
||||
|
||||
F. We prove the statement by induction. The base case is $n=0$. For $n=0$, we see that $f(0) = sum^0_(k=0) k dot k! = 0 dot 0! = 0 dot 1 = 0$ and also that $(n+1)! -1 = (0+1)!-1 = 1!-1 = 1-1 =0$. This proves the base case.
|
||||
|
||||
|
||||
G. We have that $
|
||||
f(n) &= sum^n_(k=0) k dot k! \
|
||||
&= (sum^(n+1)_(k=0) k dot k! ) - (n+1)(n+1)! \
|
||||
&= f(n+1) - (n+1)(n+1)! \
|
||||
&= ((n+1)+1)! - 1 - (n+1)(n+1)! "By the induction hypothesis" \
|
||||
&= (n+2)! -(n+1)(n+1)!-1 \
|
||||
&= (n+2)(n+1)!-(n+1)(n+1)!-1 \
|
||||
&= (n+2 - (n+1))(n+1)!-1 \
|
||||
&= (n+1)! -1
|
||||
$ which is what we wanted to prove. This concludes the induction step.
|
||||
|
||||
H. We have that $
|
||||
f(n+1) &= sum^(n+1)_(k=0) k dot k! \
|
||||
&= (sum^n_(k=0) k dot k!) + (n+1)(n+1)! \
|
||||
&= f(n)+(n+1)(n+1)! \
|
||||
&= (n+1)!-1+(n+1)(n+1)! "By the induction hypothesis" \
|
||||
&= (n+1)(n+1)!+(n+1)!-1 \
|
||||
&= [(n+1)+1](n+1)!-1 \
|
||||
&= (n+2)! - 1 = ((n+1)+1)!-1
|
||||
$ which is what we wanted to prove. This concludes the induction step.
|
||||
|
||||
#table(
|
||||
columns: (20%, auto, auto, auto, auto, auto, auto, auto, auto),
|
||||
align: (left, center, center, center, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[],
|
||||
[A],
|
||||
[B],
|
||||
[C],
|
||||
[D],
|
||||
[E],
|
||||
[F],
|
||||
[G],
|
||||
[H],
|
||||
[The first fragment is:],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's answer],
|
||||
[*Rasmus's, Sebastian's answer*],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[The second fragment is:],
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
[Rasmus's answer],
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[The third fragment is:],
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Rasmus's answer],
|
||||
[The fourth fragment is:],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
[Mikkel's answer],
|
||||
)
|
||||
|
||||
== Question 7
|
||||
|
||||
For all $n in NN$ define $a_n$ recursively as follows $a_0 = 2, a_1 = 3, a_n = cases(a_(n-1) + n "if" n "is even", a_(n-1) + 2a_(n-2) "if" n "is odd")$
|
||||
|
||||
1. 37 (All's answer)
|
||||
2. 38
|
||||
3. 35
|
||||
4. 40
|
||||
5. None of these
|
||||
6. 36
|
||||
7. 39
|
||||
|
||||
== Question 8
|
||||
|
||||
We wish to construct a bipartite graph with bipartition $(V_1, V_2)$ such that $abs(V_1) = 4, abs(V_2) = 5$ (Note that a bipartite graph has no loops, but it may contain multiple edges.)
|
||||
#table(
|
||||
columns: (40%, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center),
|
||||
[],
|
||||
[The graph exists without multiple edges.],
|
||||
[The graph exists but only if we allow multiple edges.],
|
||||
[The graph does not exist, but it will exist if we are allowed to increase one of the degrees in $V_1$.],
|
||||
[The graph does not exist, but it will exist if we are allowed to increase one of the degrees in $V_2$.],
|
||||
[None of these are correct],
|
||||
[If the degrees in $V_1$ are $5,5,5,5$ and the degrees in $V_2$ are $4,4,4,4,4$ then],
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's, Sebastian's answer],
|
||||
mark-circle,
|
||||
[If the degrees in $V_1$ are $1,2,2,2$ and the degrees in $V_2$ are $1,2,2,2,2$ then],
|
||||
[Sebastian's answer],
|
||||
[Mikkel's answer],
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[If the degrees in $V_1$ are $4,4,4,4$, and the degrees in $V_2$ are $5,5,5,5,5$ then],
|
||||
mark-circle,
|
||||
[Rasmus's answer],
|
||||
[Mikkel's, Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
|
||||
== Question 9
|
||||
|
||||
The formula $binom(m+n, r) = sum^r_(k=a) binom(m, r-k) binom(n,k)$ is true for all integers $m,n,r$ satisfying $0 < m < r < n$ if we let the summation start with:
|
||||
|
||||
1. $a = n$ (Sebastian's answer)
|
||||
2. $a = r$
|
||||
3. None of these (Rasmus's answer)
|
||||
4. $a = n -r$ (Mikkel's answer)
|
||||
5. $a = m$
|
||||
6. $a = r - m$
|
||||
|
||||
|
||||
== Question 10
|
||||
|
||||
Let $A = {0,1,2,4}, B = {0,1,3,5}, "and" C = {0,2,3,6}$. IF the universal set $U = {0,1,2,3,4,5,6,7}$, then which of hte following is equal to $((A inter B) backslash C) union ((B inter C) backslash C) union ((C inter A) backslash B)$
|
||||
|
||||
1. ${0,1,2,3}$
|
||||
2. All of these sets
|
||||
3. $emptyset$ (Mikkel's answer)
|
||||
4, ${4,5,6}$
|
||||
5. None of these
|
||||
6. ${0,4,5,6}$
|
||||
7. ${1,2,3}$ (Rasmus's, Sebastian's answer)
|
||||
|
||||
== Question 11
|
||||
|
||||
Consider the statement "for every positive rational number $x$ there are positive integers $a$ and $b$ such that $x = a/b$ and $gcd(a,b) = 1$." Which of the following statement in predicate logic is equivalent to this if we let $G(a,b)$ denote the statement " $a "and" b$ are relatively prime"?
|
||||
|
||||
1. It is not possible to translate the statement into predicate logic. (Sebastian's answer)
|
||||
2. $forall x in QQ^+ exists a in ZZ^+ exists b in ZZ^+ (x = a/b and G(a,b)) $ (Mikkel's, Rasmus's answer)
|
||||
3. $forall x in QQ^+ exists a in ZZ^+ exists b in ZZ^+ (G(a,b) -> x = a/b)$
|
||||
4. $forall x in QQ^+ forall a in ZZ^+ forall b in ZZ^+ (x = a/b and G(a,b))$
|
||||
5. $forall x in QQ^+ exists a in ZZ^+ exists b in ZZ^+ (x = a/b -> G(a,b))$
|
||||
|
||||
== Question 12
|
||||
|
||||
Given a univerisal set $U$, which of the following is equal to the set $A inter overline(B backslash C)$?
|
||||
|
||||
1. None of these
|
||||
2. $A inter B inter overline(C)$
|
||||
3. $(A union B) inter (A union overline(C))$
|
||||
4. $(A inter overline(B)) union (A inter C)$ (Rasmus's answer)
|
||||
5. $A inter overline(B) inter C$
|
||||
6. $A inter (C backslash B)$ (Mikkel's, Sebastian's answer)
|
||||
|
||||
|
||||
== Question 13
|
||||
|
||||
The empty set is an element of which of the following sets?
|
||||
|
||||
1. ${{emptyset}}$
|
||||
2. None of these
|
||||
3. $emptyset$ (Mikkel's answer)
|
||||
4. ${x in RR : x < x}$
|
||||
5. ${emptyset}$ (Rasmus's, Sebastian's answer)
|
||||
6. All of these sets
|
||||
|
||||
== Question 14
|
||||
|
||||
Which of the following are tautologies?
|
||||
|
||||
1. $(p -> q) or (not q -> not p)$ (Sebastian's answer)
|
||||
2. None of these
|
||||
3. $p <-> q$
|
||||
4. All of these
|
||||
5. $(not p or not q) -> (not (p and q))$ (Mikkel's, Rasmus's answer)
|
||||
6. $(p or q or r) and (p or not q or not r)$
|
||||
|
||||
== Question 15
|
||||
|
||||
Consider all possible seatings of $3n$ people around two tables, one with $n$ seats and one with $2n$ seats. Find the number of seatings when
|
||||
#table(
|
||||
columns: (20%, auto, auto, auto, auto, auto, auto, auto, auto, auto),
|
||||
align: (left, center, center, center, center, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[],
|
||||
[$((3n)!)/(2(n!))$],
|
||||
[$((3n)!)/(4(n!))$],
|
||||
[$((3n)!)/(4n)$],
|
||||
[$2 binom(3n,n)$],
|
||||
[$((3n)!)/(2n^2)$],
|
||||
[$((3n)!)/(4n^2)$],
|
||||
[$((3n)!)/(8n^2)$],
|
||||
[$4 binom(3n,n)$],
|
||||
[None of these],
|
||||
[Two seatings are considered the same when each person has the same left and right neighbor.],
|
||||
mark-circle,
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
[Two seatings are considered the same when each person has the same neighbors (and we do not care about right or left)],
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's answer],
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
== Question 16
|
||||
|
||||
For each of the following, determine whether it is surjective/injective, or not a well defined function. Recall that $NN$ is the set of natural numbers, in other words the set of nonnegative integers.
|
||||
|
||||
#table(
|
||||
columns: (35%, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center),
|
||||
[],
|
||||
[Not a well defined function],
|
||||
[Well defined but neither injective nor surjective],
|
||||
[Surjective],
|
||||
[Injective],
|
||||
[Both injective and surjective],
|
||||
[$ f: RR -> ZZ $ given by $f(x) = 2 floor(x/2)$],
|
||||
[Mikkel's, Sebastian's answer],
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$f : RR -> {x in RR : x >= 0}$ given by $f(x) = sqrt(x^2)$],
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
[Mikkel's answer],
|
||||
[$f: NN -> NN$ given by $f(x) = 2x +7$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[All's answer],
|
||||
mark-circle,
|
||||
[$f: NN -> NN$ given by $f(x) = x-x^2$],
|
||||
[Rasmus's, Sebastian's answer],
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$f: RR -> RR$ given by $f(x) = cases(x "if" x in QQ, -x "if" x in.not QQ)$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's, Sebastian's answer],
|
||||
mark-circle,
|
||||
[Rasmus's answer],
|
||||
)
|
||||
|
||||
== Question 17
|
||||
|
||||
Consider all permutations of ABCDE
|
||||
#table(
|
||||
columns: (20%, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center, center, center),
|
||||
[],
|
||||
[12],
|
||||
[24],
|
||||
[36],
|
||||
[48],
|
||||
[50],
|
||||
[64],
|
||||
[None of these],
|
||||
[How many contain none of AB, BC, CD],
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
[How many contain ACE],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
[Mikkel's, Rasmus's answer],
|
||||
[How many contain precisely one of AB, CD],
|
||||
mark-circle,
|
||||
[Mikkels's, Sebastian's answer],
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle
|
||||
)
|
||||
|
||||
== Question 18
|
||||
|
||||
For each relation on the set of four distinct elements $a,b,c,d$ below, decide which property it has.
|
||||
|
||||
#table(
|
||||
columns: (30%, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center, center, center),
|
||||
stroke: none,
|
||||
[],
|
||||
[The edges of a hasse diagram],
|
||||
[Partial order],
|
||||
[Total order but not well ordered],
|
||||
[Well-order],
|
||||
[None of these],
|
||||
[Total order but not partial order],
|
||||
[Equivalence relation],
|
||||
[$(a,a),(a,b),(a,c)(a,d)$],
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's answer],
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$(a,b),(b,c),(c,d)$],
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Mikkel's, Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$(a,a),(b,b),(c,c),\ (d,d),(a,d),(d,a)$],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
[Mikkel's, Rasmus's answer],
|
||||
[$(a,a),(b,b),(c,c),\ (d,d),(d,c)$],
|
||||
mark-circle,
|
||||
[Mikkel's, Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
[$(a,a),(b,b),(c,c),(d,d),\ (a,b),(a,c),(a,d),(b,c),\ (b,d),(c,d)$],
|
||||
[Mikkel's answer],
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer]
|
||||
)
|
||||
|
||||
|
||||
== Question 19
|
||||
|
||||
Which of the following is a recursively defined function for the number of ways to tile an $n times 2$ board using $2 times 1$ tiles.
|
||||
|
||||
1. $f(0) = 1, f(1) = 1, f(n) = f(n - 1) + f(n - 2) "for" n >= 2$
|
||||
2. $f(0) = 0, f(1) = 1, f(n) = 2f(n - 2) "for" n >= 2$
|
||||
3. $f(0) = 1, f(1) = 1, f(n) = 2f(n - 2) "for" n >= 2$
|
||||
4. $f(0) = 1, f(1) = 1, f(n) = f(n - 1)f(n - 2) "for" n >= 2$
|
||||
5. All of these (Mikkel's answer)
|
||||
6. $f(0) = 0, f(1) = 1, f(n) = f(n - 1) + f(n - 2) "for" n >= 2$ (Rasmus's, Sebastian's answer)
|
||||
7. None of these
|
||||
|
||||
|
||||
== Question 20
|
||||
|
||||
Find the coefficient of $x^15 y^20$ in the polynomials below.
|
||||
|
||||
#table(
|
||||
columns: (20%, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1fr),
|
||||
align: (left, center, center, center, center, center, center, center),
|
||||
[],
|
||||
[$- binom(10,5)2^5$],
|
||||
[$binom(10,5) 2^15$],
|
||||
[$- binom(10,5)2^15$],
|
||||
[0],
|
||||
[None of these],
|
||||
[$-binom(10,5)2^10$],
|
||||
[$- binom(10,3)2^5$],
|
||||
[$(2x^3-y^4)^10$],
|
||||
[Mikkel's, Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$(1-2x^3y^4)^10$],
|
||||
[Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
[Mikkel's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[$(x^3-2y^4)^10$],
|
||||
[Mikkel's, Rasmus's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
[Sebastian's answer],
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
mark-circle,
|
||||
)
|
||||
|
||||
|
||||
== Question 21
|
||||
|
||||
Which of the following is equivalent to the statement " $a$ and $b$ are relatively prime"? The domain for each statement is
|
||||
the set of all positive integers
|
||||
|
||||
1. None of these three are equivalent to the statement.
|
||||
2. $not (exists c (c divides a and c divides b and c > 1) )$ is equivalent to the statement, and the other two are not.
|
||||
3. $forall c (not (c divides a) or not (c divides b) or (c <= 1))$ is equivalent to the statement, and the other two are not.
|
||||
4. All of these three are equivalent to the statement.
|
||||
5. $forall c ( (c divides a and c divides b) -> (c <= 1))$ is equivalent to the statement, and other two are not. (All's answer)
|
||||
|
||||
BIN
Diskret Mat/ipynb filer/__pycache__/discrete.cpython-313.pyc
Normal file
BIN
Diskret Mat/ipynb filer/__pycache__/discrete.cpython-313.pyc
Normal file
Binary file not shown.
1706
Diskret Mat/ipynb filer/discMatSympy.ipynb
Normal file
1706
Diskret Mat/ipynb filer/discMatSympy.ipynb
Normal file
File diff suppressed because it is too large
Load Diff
370
Diskret Mat/ipynb filer/discrete.py
Normal file
370
Diskret Mat/ipynb filer/discrete.py
Normal file
@@ -0,0 +1,370 @@
|
||||
import math
|
||||
import re as regex
|
||||
from itertools import combinations, permutations
|
||||
|
||||
import pandas as pd
|
||||
from sympy import *
|
||||
from sympy.ntheory.modular import crt
|
||||
from math import comb
|
||||
init_printing()
|
||||
|
||||
def superscriptify(expr):
|
||||
"""Convert an expression's powers (**) into unicode superscripts and leave multiplication as is."""
|
||||
if expr is None:
|
||||
return "*"
|
||||
s = str(expr)
|
||||
|
||||
# Map digits and minus sign to superscripts
|
||||
superscript_map = {
|
||||
'0': '⁰', '1': '¹', '2': '²', '3': '³', '4': '⁴',
|
||||
'5': '⁵', '6': '⁶', '7': '⁷', '8': '⁸', '9': '⁹',
|
||||
'-': '⁻'
|
||||
}
|
||||
|
||||
def replace_power(match):
|
||||
exponent_str = match.group(1)
|
||||
# Convert each character of the exponent to its superscript equivalent
|
||||
return ''.join(superscript_map.get(ch, ch) for ch in exponent_str)
|
||||
|
||||
# Replace all occurrences of '**<integer>' with the corresponding superscript characters
|
||||
s = regex.sub(r'\*\*(-?\d+)', lambda m: replace_power(m), s)
|
||||
|
||||
return s
|
||||
|
||||
|
||||
'''
|
||||
EUCLIDEAN ALGORITHM FUNCTIONS
|
||||
'''
|
||||
|
||||
def extended_euclidean_algorithm_polys(N: Poly, M: Poly, x: Symbol, beatify: bool = true):
|
||||
# Initialize variables for the extended Euclidean algorithm
|
||||
r = [N, M] # Remainders
|
||||
s = [Poly(1, x), Poly(0, x)] # Coefficients of N(x)
|
||||
t = [Poly(0, x), Poly(1, x)] # Coefficients of M(x)
|
||||
|
||||
# Perform the extended Euclidean algorithm
|
||||
k = 0
|
||||
while r[k+1] != 0:
|
||||
quotient, remainder = div(r[k], r[k+1])
|
||||
r.append(remainder)
|
||||
if remainder == 0:
|
||||
s.append(None)
|
||||
t.append(None)
|
||||
else:
|
||||
s.append(s[k] - quotient * s[k+1])
|
||||
t.append(t[k] - quotient * t[k+1])
|
||||
k += 1
|
||||
|
||||
results = []
|
||||
for i in range(len(r)):
|
||||
if beatify:
|
||||
r_str = superscriptify(r[i].as_expr() if r[i] is not None else None)
|
||||
s_str = superscriptify(s[i].as_expr() if s[i] is not None else None)
|
||||
t_str = superscriptify(t[i].as_expr() if t[i] is not None else None)
|
||||
else:
|
||||
r_str = r[i].as_expr() if r[i] is not None else None
|
||||
s_str = s[i].as_expr() if s[i] is not None else None
|
||||
t_str = t[i].as_expr() if t[i] is not None else None
|
||||
results.append({
|
||||
"k": i,
|
||||
"r_k(x)": r_str,
|
||||
"s_k(x)": s_str,
|
||||
"t_k(x)": t_str
|
||||
})
|
||||
|
||||
df = pd.DataFrame(results)
|
||||
return df
|
||||
|
||||
def extended_euclidean_algorithm_integers(a, b, beautify: bool = True):
|
||||
"""
|
||||
Compute the Extended Euclidean Algorithm steps for two integers a and b.
|
||||
|
||||
Returns a DataFrame with columns:
|
||||
k, r_k, s_k, t_k
|
||||
such that r_k = s_k*a + t_k*b at each step.
|
||||
"""
|
||||
# Initializations
|
||||
r = [a, b]
|
||||
s = [1, 0]
|
||||
t = [0, 1]
|
||||
|
||||
k = 0
|
||||
while r[k+1] != 0:
|
||||
quotient = r[k] // r[k+1]
|
||||
remainder = r[k] % r[k+1]
|
||||
r.append(remainder)
|
||||
|
||||
if remainder == 0:
|
||||
s.append(None)
|
||||
t.append(None)
|
||||
else:
|
||||
s.append(s[k] - quotient * s[k+1])
|
||||
t.append(t[k] - quotient * t[k+1])
|
||||
k += 1
|
||||
|
||||
results = []
|
||||
for i in range(len(r)):
|
||||
if beautify:
|
||||
r_str = superscriptify(r[i]) if r[i] is not None else None
|
||||
s_str = superscriptify(s[i]) if s[i] is not None else None
|
||||
t_str = superscriptify(t[i]) if t[i] is not None else None
|
||||
else:
|
||||
r_str = r[i]
|
||||
s_str = s[i]
|
||||
t_str = t[i]
|
||||
results.append({
|
||||
"k": i,
|
||||
"r_k": r_str,
|
||||
"s_k": s_str,
|
||||
"t_k": t_str
|
||||
})
|
||||
|
||||
df = pd.DataFrame(results)
|
||||
return df
|
||||
|
||||
class PermutationFilter:
|
||||
def __init__(self, sequence):
|
||||
self.sequence = sequence
|
||||
# Generate all permutations of the given sequence as tuples
|
||||
self.all_permutations = list(permutations(self.sequence))
|
||||
|
||||
def filter_permutations(self, include_substrings=None, exclude_substrings=None):
|
||||
"""
|
||||
Filter permutations based on optional inclusion and exclusion criteria.
|
||||
|
||||
:param include_substrings: A list of substrings. A permutation must contain
|
||||
at least one of these substrings to pass.
|
||||
:param exclude_substrings: A list of substrings. A permutation must not contain
|
||||
any of these substrings to pass.
|
||||
|
||||
:return: A list of permutations (as tuples) that match the criteria.
|
||||
"""
|
||||
filtered = self.all_permutations
|
||||
|
||||
# Convert tuple permutations into strings for checking
|
||||
# We'll do this step once to avoid repeating it for each condition
|
||||
filtered_strings = [''.join(p) for p in filtered]
|
||||
|
||||
# If include_substrings is given, keep only those permutations that contain
|
||||
# at least one of the given substrings
|
||||
if include_substrings:
|
||||
new_filtered = []
|
||||
new_filtered_strings = []
|
||||
for perm_str, perm_tuple in zip(filtered_strings, filtered):
|
||||
if any(sub in perm_str for sub in include_substrings):
|
||||
new_filtered.append(perm_tuple)
|
||||
new_filtered_strings.append(perm_str)
|
||||
filtered = new_filtered
|
||||
filtered_strings = new_filtered_strings
|
||||
|
||||
# If exclude_substrings is given, remove any permutations that contain
|
||||
# any of the given substrings
|
||||
if exclude_substrings:
|
||||
new_filtered = []
|
||||
new_filtered_strings = []
|
||||
for perm_str, perm_tuple in zip(filtered_strings, filtered):
|
||||
if not any(sub in perm_str for sub in exclude_substrings):
|
||||
new_filtered.append(perm_tuple)
|
||||
new_filtered_strings.append(perm_str)
|
||||
filtered = new_filtered
|
||||
filtered_strings = new_filtered_strings
|
||||
|
||||
return filtered
|
||||
|
||||
def derangement_formula(n):
|
||||
""" Calculate the number of derangements using the direct formula. """
|
||||
derangements = math.factorial(n) * sum(((-1) ** k) / math.factorial(k) for k in range(n + 1))
|
||||
return int(derangements)
|
||||
|
||||
def count_edges_in_n_cube(n):
|
||||
# Number of edges in the n-cube graph
|
||||
return n * (2 ** (n - 1))
|
||||
|
||||
def guaranteed_selection_count(target, numbers):
|
||||
# Step 1: Find all subsets whose sum equals the target
|
||||
target_subsets = []
|
||||
for r in range(1, len(numbers) + 1):
|
||||
for subset in combinations(numbers, r):
|
||||
if sum(subset) == target:
|
||||
target_subsets.append(set(subset))
|
||||
|
||||
# If no subset sums to the target, no finite number will guarantee it.
|
||||
if not target_subsets:
|
||||
return float('inf') # or len(numbers) + 1, depending on your preference
|
||||
|
||||
# Step 2: Find the maximum subset of 'numbers' that does NOT contain any target-sum subset fully
|
||||
# We'll brute force all subsets of 'numbers' and check.
|
||||
# For each candidate subset, we must ensure it does not include any of the target_subsets fully.
|
||||
# i.e., For every target_subset T, candidate_subset should not be a superset of T.
|
||||
|
||||
max_safe_size = 0
|
||||
n = len(numbers)
|
||||
for r in range(n + 1):
|
||||
for candidate in combinations(numbers, r):
|
||||
candidate_set = set(candidate)
|
||||
# Check if candidate_set fully contains any target_subset
|
||||
if any(t_subset.issubset(candidate_set) for t_subset in target_subsets):
|
||||
# This candidate is not safe because it contains a full target-sum subset
|
||||
continue
|
||||
# If it passes all checks, update max_safe_size
|
||||
max_safe_size = max(max_safe_size, r)
|
||||
|
||||
# Step 3: Once you exceed max_safe_size by 1, you guarantee forming a target subset
|
||||
return max_safe_size + 1
|
||||
|
||||
def check_relation_properties(A, R):
|
||||
# Convert R to a set for faster membership testing if needed
|
||||
R_set = set(R)
|
||||
|
||||
# Check Reflexive: (a,a) in R for all a in A
|
||||
reflexive = all((a, a) in R_set for a in A)
|
||||
|
||||
# Check Symmetric: For every (a,b) in R, (b,a) must also be in R
|
||||
symmetric = all((b, a) in R_set for (a, b) in R_set)
|
||||
|
||||
# Check Antisymmetric: If (a,b) and (b,a) in R, then a must be b
|
||||
# If we ever find a != b with both (a,b) and (b,a), it's not antisymmetric.
|
||||
antisymmetric = True
|
||||
for (a, b) in R_set:
|
||||
if a != b and (b, a) in R_set:
|
||||
antisymmetric = False
|
||||
break
|
||||
|
||||
# Check Transitive: If (a,b) and (b,c) in R, then (a,c) must be in R
|
||||
# We'll use a nested loop approach.
|
||||
transitive = True
|
||||
for (a, b) in R_set:
|
||||
for (x, y) in R_set:
|
||||
if b == x and (a, y) not in R_set:
|
||||
transitive = False
|
||||
break
|
||||
if not transitive:
|
||||
break
|
||||
|
||||
# Return a dictionary or tuple of results
|
||||
return {
|
||||
"reflexive": reflexive,
|
||||
"symmetric": symmetric,
|
||||
"antisymmetric": antisymmetric,
|
||||
"transitive": transitive
|
||||
}
|
||||
|
||||
def test_formula(formula_func, reference_func, test_values=range(1, 11)):
|
||||
"""
|
||||
Test a given formula function against a given reference function for a range of test values.
|
||||
Returns True if formula_func(n) == reference_func(n) for all tested values of n, False otherwise.
|
||||
"""
|
||||
for n in test_values:
|
||||
lhs = formula_func(n)
|
||||
rhs = reference_func(n)
|
||||
if lhs != rhs:
|
||||
return False
|
||||
return True
|
||||
|
||||
def solve_linear_congruence(a, b, m):
|
||||
g = gcd(a, m)
|
||||
# Tjek om løsning eksisterer
|
||||
if b % g != 0:
|
||||
return None
|
||||
|
||||
# Reducer
|
||||
a_red = a // g
|
||||
b_red = b // g
|
||||
m_red = m // g
|
||||
|
||||
a_inv = mod_inverse(a_red, m_red)
|
||||
x0 = (b_red * a_inv) % m_red
|
||||
|
||||
return (x0, m_red, g)
|
||||
|
||||
def solve_system_congruences(equations):
|
||||
"""
|
||||
Solve a system of linear congruences given by:
|
||||
equations = [(A1, B1, M1), (A2, B2, M2), ...]
|
||||
meaning A_i * x ≡ B_i (mod M_i).
|
||||
|
||||
Returns: (solution, modulus) if a solution exists, otherwise None.
|
||||
"""
|
||||
moduli = []
|
||||
remainders = []
|
||||
|
||||
for (A, B, M) in equations:
|
||||
g = gcd(A, M)
|
||||
# Check if solution exists for this congruence
|
||||
if B % g != 0:
|
||||
return None # No solution
|
||||
|
||||
# Reduce the congruence
|
||||
A_red = A // g
|
||||
B_red = B // g
|
||||
M_red = M // g
|
||||
|
||||
# Compute the inverse of A_red mod M_red
|
||||
A_inv = mod_inverse(A_red, M_red)
|
||||
# Compute a particular solution x0
|
||||
x0 = (B_red * A_inv) % M_red
|
||||
|
||||
moduli.append(M_red)
|
||||
remainders.append(x0)
|
||||
|
||||
# Now solve the standard form system x ≡ remainders[i] (mod moduli[i])
|
||||
solution, modulus = crt(moduli, remainders)
|
||||
return (solution, modulus)
|
||||
|
||||
def graph_properties_all(n, m=None):
|
||||
"""
|
||||
Calculates the number of edges and vertices for multiple standard graph types.
|
||||
|
||||
Parameters:
|
||||
n (int): A parameter related to the graph type (e.g., vertices or dimension for cube).
|
||||
m (int, optional): For bipartite graphs, the size of the second partition.
|
||||
|
||||
Returns:
|
||||
dict: A dictionary of all graph types with their properties or a message if not applicable.
|
||||
"""
|
||||
results = {}
|
||||
|
||||
# Cube graph (n-dimensional hypercube)
|
||||
try:
|
||||
vertices = 2**n
|
||||
edges = n * 2**(n-1)
|
||||
results["Cube Graph"] = {"Vertices": vertices, "Edges": edges}
|
||||
except Exception:
|
||||
results["Cube Graph"] = "Not defined for n = {}".format(n)
|
||||
|
||||
# Complete graph
|
||||
try:
|
||||
vertices = n
|
||||
edges = n * (n - 1) // 2
|
||||
results["Complete Graph"] = {"Vertices": vertices, "Edges": edges}
|
||||
except Exception:
|
||||
results["Complete Graph"] = "Not defined for n = {}".format(n)
|
||||
|
||||
# Bipartite graph K(m, n)
|
||||
try:
|
||||
if m is not None:
|
||||
vertices = n + m
|
||||
edges = n * m
|
||||
results["Bipartite Graph"] = {"Vertices": vertices, "Edges": edges}
|
||||
else:
|
||||
results["Bipartite Graph"] = "Requires both partitions (n and m)."
|
||||
except Exception:
|
||||
results["Bipartite Graph"] = "Not defined for n = {}, m = {}".format(n, m)
|
||||
|
||||
# Cycle graph
|
||||
try:
|
||||
vertices = n
|
||||
edges = n
|
||||
results["Cycle Graph"] = {"Vertices": vertices, "Edges": edges}
|
||||
except Exception:
|
||||
results["Cycle Graph"] = "Not defined for n = {}".format(n)
|
||||
|
||||
# Wheel graph
|
||||
try:
|
||||
vertices = n
|
||||
edges = 2 * (n - 1)
|
||||
results["Wheel Graph"] = {"Vertices": vertices, "Edges": edges}
|
||||
except Exception:
|
||||
results["Wheel Graph"] = "Not defined for n = {}".format(n)
|
||||
|
||||
return results
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user