question stringlengths 6 3.53k | text stringlengths 17 2.05k | source stringclasses 1
value |
|---|---|---|
From a corpus of \( N \) occurences of \( m \) different tokens:How many different 4-grams (values) could you possibly have? | Using a modification of byte-pair encoding, in the first step, all unique characters (including blanks and punctuation marks) are treated as an initial set of n-grams (i.e. initial set of uni-grams). Successively the most frequent pair of adjacent characters is merged into a bi-gram and all instances of the pair are re... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
From a corpus of \( N \) occurences of \( m \) different tokens:How many different 4-grams (values) could you possibly have? | This is repeated until a vocabulary of prescribed size is obtained. Note that new words can always be constructed from final vocabulary tokens and initial-set characters.All the unique tokens found in a corpus are listed in a token vocabulary, the size of which, in the case of GPT-3, is 50257. The difference between th... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
You have been publishing a daily column for the Gazette over the last few years and have recently reached a milestone --- your 1000th column! Realizing you'd like to go skiing more often, you decide it might be easier to automate your job by training a story generation system on the columns you've already written. Then... | The original paper on generative pre-training of a transformer-based language model was written by Alec Radford and his colleagues, and published in preprint on OpenAI's website on June 11, 2018. It showed how a generative model of language is able to acquire world knowledge and process long-range dependencies by pre-t... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
You have been publishing a daily column for the Gazette over the last few years and have recently reached a milestone --- your 1000th column! Realizing you'd like to go skiing more often, you decide it might be easier to automate your job by training a story generation system on the columns you've already written. Then... | The original paper on generative pre-training of a transformer-based language model was written by Alec Radford and his colleagues, and published in preprint on OpenAI's website on June 11, 2018. It showed how a generative model of language is able to acquire world knowledge and process long-range dependencies by pre-t... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
You have been provided with the following definitions for the possible meanings of the words "balloon" and "plane":
balloon:
- meaning 1:
balloon --(hyponym)--> inflatable
- meaning 2:
balloon --(hyponym)--> transport
plane:
- meaning 1:
plane --(hyponym)--> transport
plane --(holonym)--> wing
- meaning 2:
pl... | A semantic difficulty may arise when considering reference in representationalism. If a person says "I see the Eiffel Tower" at a time when they are indeed looking at the Eiffel Tower, to what does the term "Eiffel Tower" refer? The direct realist might say that in the representational account people do not really see ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
You have been provided with the following definitions for the possible meanings of the words "balloon" and "plane":
balloon:
- meaning 1:
balloon --(hyponym)--> inflatable
- meaning 2:
balloon --(hyponym)--> transport
plane:
- meaning 1:
plane --(hyponym)--> transport
plane --(holonym)--> wing
- meaning 2:
pl... | A semantic difficulty may arise when considering reference in representationalism. If a person says "I see the Eiffel Tower" at a time when they are indeed looking at the Eiffel Tower, to what does the term "Eiffel Tower" refer? The direct realist might say that in the representational account people do not really see ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
In this problem we are going to investigate the linear programming relaxation of a classical scheduling problem. In the considered problem, we are given a set $M$ of $m$ machines and a set $J$ of $n$ jobs. Each job $j\in J$ has a processing time $p_j > 0$ and can be processed on a subset $N(j) \subseteq M$ of the machi... | A natural way to formulate the problem as a linear program is called the Lenstra–Shmoys–Tardos linear program (LST LP). For each machine i and job j, define a variable z i , j {\displaystyle z_{i,j}} , which equals 1 iff machine i processes job j, and 0 otherwise. Then, the LP constraints are: ∑ i = 1 m z i , j = 1 {\d... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
In this problem we are going to investigate the linear programming relaxation of a classical scheduling problem. In the considered problem, we are given a set $M$ of $m$ machines and a set $J$ of $n$ jobs. Each job $j\in J$ has a processing time $p_j > 0$ and can be processed on a subset $N(j) \subseteq M$ of the machi... | Using the technique of Linear programming relaxation, it is possible to approximate the optimal scheduling with slightly better approximation factors. The approximation ratio of the first such algorithm is asymptotically 2 when k is large, but when k=2 the algorithm achieves an approximation ratio of 5/3. The approxima... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
A multiset is an unordered collection where elements can appear multiple times. We will represent a multiset of Char elements as a function from Char to Int: the function returns 0 for any Char argument that is not in the multiset, and the (positive) number of times it appears otherwise: type Multiset = Char => Int Ass... | A multiset may be formally defined as an ordered pair (A, m) where A is the underlying set of the multiset, formed from its distinct elements, and m: A → Z + {\displaystyle m\colon A\to \mathbb {Z} ^{+}} is a function from A to the set of positive integers, giving the multiplicity – that is, the number of occurrences –... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
A multiset is an unordered collection where elements can appear multiple times. We will represent a multiset of Char elements as a function from Char to Int: the function returns 0 for any Char argument that is not in the multiset, and the (positive) number of times it appears otherwise: type Multiset = Char => Int Ass... | The set of all bags over type T is given by the expression bag T. If by multiset one considers equal items identical and simply counts them, then a multiset can be interpreted as a function from the input domain to the non-negative integers (natural numbers), generalizing the identification of a set with its indicator ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Given a matroid $\mathcal{M}= (E, \mathcal{I})$ and a weight function $w: E \rightarrow \mathbb{R}$,~\textsc{Greedy} for matroids returns a base $S = \{s_1, s_2, \dots, s_k\}$ of maximum weight. As noted in the lecture notes, any base consists of the same number, say $k$, of elements (which is said to be the rank o... | In combinatorics, a branch of mathematics, a weighted matroid is a matroid endowed with function with respect to which one can perform a greedy algorithm. A weight function w: E → R + {\displaystyle w:E\rightarrow \mathbb {R} ^{+}} for a matroid M = ( E , I ) {\displaystyle M=(E,I)} assigns a strictly positive weight t... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Given a matroid $\mathcal{M}= (E, \mathcal{I})$ and a weight function $w: E \rightarrow \mathbb{R}$,~\textsc{Greedy} for matroids returns a base $S = \{s_1, s_2, \dots, s_k\}$ of maximum weight. As noted in the lecture notes, any base consists of the same number, say $k$, of elements (which is said to be the rank o... | A weighted matroid is a matroid together with a function from its elements to the nonnegative real numbers. The weight of a subset of elements is defined to be the sum of the weights of the elements in the subset. The greedy algorithm can be used to find a maximum-weight basis of the matroid, by starting from the empty... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider the Maximum Disjoint Paths problem: given an undirected graph $G=(V,E)$ with designated source $s\in V$ and sink $t\in V\setminus \{s\}$ vertices, find the maximum number of edge-disjoint paths from $s$ to $t$. To formulate it as a linear program, we have a variable $x_p$ for each possible path $p$ that starts... | Given a directed graph G = ( V , E ) {\displaystyle G=(V,E)} and two vertices s {\displaystyle s} and t {\displaystyle t} , we are to find the maximum number of paths from s {\displaystyle s} to t {\displaystyle t} . This problem has several variants: 1. The paths must be edge-disjoint. This problem can be transformed ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider the Maximum Disjoint Paths problem: given an undirected graph $G=(V,E)$ with designated source $s\in V$ and sink $t\in V\setminus \{s\}$ vertices, find the maximum number of edge-disjoint paths from $s$ to $t$. To formulate it as a linear program, we have a variable $x_p$ for each possible path $p$ that starts... | In the undirected edge-disjoint paths problem, we are given an undirected graph G = (V, E) and two vertices s and t, and we have to find the maximum number of edge-disjoint s-t paths in G. Menger's theorem states that the maximum number of edge-disjoint s-t paths in an undirected graph is equal to the minimum number of... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
In this problem, we give a $2$-approximation algorithm for the submodular vertex cover problem which is a generalization of the classic vertex cover problem seen in class. We first, in subproblem~\textbf{(a)}, give a new rounding for the classic vertex cover problem and then give the algorithm for the more general pr... | Assume that every vertex has an associated cost of c ( v ) ≥ 0 {\displaystyle c(v)\geq 0} . The (weighted) minimum vertex cover problem can be formulated as the following integer linear program (ILP). This ILP belongs to the more general class of ILPs for covering problems. The integrality gap of this ILP is 2 {\displa... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
In this problem, we give a $2$-approximation algorithm for the submodular vertex cover problem which is a generalization of the classic vertex cover problem seen in class. We first, in subproblem~\textbf{(a)}, give a new rounding for the classic vertex cover problem and then give the algorithm for the more general pr... | The vertex cover problem involves finding a set of vertices that touches every edge of the graph. It is NP-hard but can be approximated to within an approximation ratio of two, for instance by taking the endpoints of the matched edges in any maximal matching. Evidence that this is the best possible approximation ratio ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
A multiset is an unordered collection where elements can appear multiple times. We will represent a
multiset of Char elements as a function from Char to Int: the function returns 0 for any Char argument that
is not in the multiset, and the (positive) number of times it appears otherwise:
1 type Multiset = Char => Int
T... | A multiset may be formally defined as an ordered pair (A, m) where A is the underlying set of the multiset, formed from its distinct elements, and m: A → Z + {\displaystyle m\colon A\to \mathbb {Z} ^{+}} is a function from A to the set of positive integers, giving the multiplicity – that is, the number of occurrences –... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
A multiset is an unordered collection where elements can appear multiple times. We will represent a
multiset of Char elements as a function from Char to Int: the function returns 0 for any Char argument that
is not in the multiset, and the (positive) number of times it appears otherwise:
1 type Multiset = Char => Int
T... | The multiset construction, denoted A = M { B } {\displaystyle {\mathcal {A}}={\mathfrak {M}}\{{\mathcal {B}}\}} is a generalization of the set construction. In the set construction, each element can occur zero or one times. In a multiset, each element can appear an arbitrary number of times. | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Given the following function sums:
1 def add(c: Int, acc: List[(Int, Int)]): List[(Int, Int)] = acc match
2 case Nil => List((c, 1))
3 case x :: xs => if x._1 == c then (c, x._2+1) :: xs else x :: add(c, xs)
4
5 def sums(digits: List[Int]): List[(Int, Int)] =
6 digits.foldRight(List[(Int, Int)]())(add)
Your task is to ... | At this point there are two single-digit numbers, the first derived from the first operand and the second derived from the second operand. Apply the originally specified operation to the two condensed operands, and then apply the summing-of-digits procedure to the result of the operation. Sum the digits of the result t... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Given the following function sums:
1 def add(c: Int, acc: List[(Int, Int)]): List[(Int, Int)] = acc match
2 case Nil => List((c, 1))
3 case x :: xs => if x._1 == c then (c, x._2+1) :: xs else x :: add(c, xs)
4
5 def sums(digits: List[Int]): List[(Int, Int)] =
6 digits.foldRight(List[(Int, Int)]())(add)
Your task is to ... | After applying an arithmetic operation to two operands and getting a result, the following procedure can be used to improve confidence in the correctness of the result: Sum the digits of the first operand; any 9s (or sets of digits that add to 9) can be counted as 0. If the resulting sum has two or more digits, sum tho... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Implement a function that takes a list ls as argument, and returns a list of all the suffixes of ls. That is, given a list List(a,b,c,...) it returns List(List(a,b,c,...), List(b,c,...), List(c,...), List(...), ..., List()). Implement the function recursively using only Nil (empty), :: (cons) and pattern matching. def ... | As the syntax supports alternative patterns in function definitions, we can continue the definition extending it to take more generic arguments: Here, the first n is a single variable pattern, which will match absolutely any argument and bind it to name n to be used in the rest of the definition. In Haskell (unlike at ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Implement a function that takes a list ls as argument, and returns a list of all the suffixes of ls. That is, given a list List(a,b,c,...) it returns List(List(a,b,c,...), List(b,c,...), List(c,...), List(...), ..., List()). Implement the function recursively using only Nil (empty), :: (cons) and pattern matching. def ... | This can lead to stack overflows when one reaches the end of the list and tries to evaluate the resulting potentially gigantic expression. For this reason, such languages often provide a stricter variant of left folding which forces the evaluation of the initial parameter before making the recursive call. In Haskell th... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Suppose we use the Simplex method to solve the following linear program: \begin{align*} \textbf{maximize} \hspace{0.8cm} & 2x_1 - x_2 \\ \textbf{subject to}\hspace{0.8cm} & x_1 - x_2 + s_1 = 1 \\ \hspace{0.8cm} & \hspace{0.85cm}x_1 + s_2 = 4 \\ \hspace{0.8cm} & \hspace{0.85cm} x_2 + s_3 = 2 \\ \hspace{0.8cm} &\hsp... | Let a linear program be given by a canonical tableau. The simplex algorithm proceeds by performing successive pivot operations each of which give an improved basic feasible solution; the choice of pivot element at each step is largely determined by the requirement that this pivot improves the solution. | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Suppose we use the Simplex method to solve the following linear program: \begin{align*} \textbf{maximize} \hspace{0.8cm} & 2x_1 - x_2 \\ \textbf{subject to}\hspace{0.8cm} & x_1 - x_2 + s_1 = 1 \\ \hspace{0.8cm} & \hspace{0.85cm}x_1 + s_2 = 4 \\ \hspace{0.8cm} & \hspace{0.85cm} x_2 + s_3 = 2 \\ \hspace{0.8cm} &\hsp... | Using the simplex method to solve a linear program produces a set of equations of the form x i + ∑ j a ¯ i , j x j = b ¯ i {\displaystyle x_{i}+\sum _{j}{\bar {a}}_{i,j}x_{j}={\bar {b}}_{i}} where xi is a basic variable and the xj's are the nonbasic variables (i.e. the basic solution which is an optimal solution to the... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Does the following code compile? val x = 12 def foo(x: List[Int]): Int = x match \t case Nil => 0 \t case x :: xs => x | In Scala, the bottom type is denoted as Nothing. Besides its use for functions that just throw exceptions or otherwise don't return normally, it's also used for covariant parameterized types. For example, Scala's List is a covariant type constructor, so List is a subtype of List for all types A. So Scala's Nil, the obj... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Does the following code compile? val x = 12 def foo(x: List[Int]): Int = x match \t case Nil => 0 \t case x :: xs => x | In Scala, functions are objects, and a convenient syntax exists for specifying anonymous functions. An example is the expression x => x < 2, which specifies a function with one parameter, that compares its argument to see if it is less than 2. It is equivalent to the Lisp form (lambda (x) (< x 2)). Note that neither th... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Chef Baker Buttersweet just took over his family business - baking tasty cakes! He notices that he has $m$ different ingredients in various quantities. In particular, he has $b_i \geq 0$ kilograms of ingredient $i$ for $i = 1, \dots, m$. His family cookbook has recipes for $n$ types of mouthwatering cakes. A kilogram o... | The following algorithms can be used to find an envy-free cake-cutting with maximum sum-of-utilities, for a cake which is a 1-dimensional interval, when each person may receive disconnected pieces and the value functions are additive: For n {\displaystyle n} partners with piecewise-constant valuations: divide the cake ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Chef Baker Buttersweet just took over his family business - baking tasty cakes! He notices that he has $m$ different ingredients in various quantities. In particular, he has $b_i \geq 0$ kilograms of ingredient $i$ for $i = 1, \dots, m$. His family cookbook has recipes for $n$ types of mouthwatering cakes. A kilogram o... | At most ( k − 1 ) n {\displaystyle (k-1)n} cuts are needed, and this is optimal. Consider now the case k=2 and arbitrary weights. Stromquist and Woodall proved that there exists an exact division of a pie (a circular cake) in which each piece contains at most n-1 intervals; hence, at most 2n-2 cuts are needed. | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Given the following function sums:
1 def add(c: Int, acc: List[(Int, Int)]): List[(Int, Int)] = acc match
2 case Nil => List((c, 1))
3 case x :: xs => if x._1 == c then (c, x._2+1) :: xs else x :: add(c, xs)
4
5 def sums(digits: List[Int]): List[(Int, Int)] =
6 digits.foldRight(List[(Int, Int)]())(add)
Your task is to ... | At this point there are two single-digit numbers, the first derived from the first operand and the second derived from the second operand. Apply the originally specified operation to the two condensed operands, and then apply the summing-of-digits procedure to the result of the operation. Sum the digits of the result t... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Given the following function sums:
1 def add(c: Int, acc: List[(Int, Int)]): List[(Int, Int)] = acc match
2 case Nil => List((c, 1))
3 case x :: xs => if x._1 == c then (c, x._2+1) :: xs else x :: add(c, xs)
4
5 def sums(digits: List[Int]): List[(Int, Int)] =
6 digits.foldRight(List[(Int, Int)]())(add)
Your task is to ... | After applying an arithmetic operation to two operands and getting a result, the following procedure can be used to improve confidence in the correctness of the result: Sum the digits of the first operand; any 9s (or sets of digits that add to 9) can be counted as 0. If the resulting sum has two or more digits, sum tho... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Change Karger's algorithm so that it also works for edge-weighted graphs. Also adapt the analysis to prove that it still returns any min cut $(S^*, \overline{S^*})$ with probability at least $1/{n \choose 2}$. (Hence, edge-weighted graphs also have at most ${n \choose 2}$ min cuts.) | The minimum cut problem in undirected, weighted graphs limited to non-negative weights can be solved in polynomial time by the Stoer-Wagner algorithm. In the special case when the graph is unweighted, Karger's algorithm provides an efficient randomized method for finding the cut. In this case, the minimum cut equals th... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Change Karger's algorithm so that it also works for edge-weighted graphs. Also adapt the analysis to prove that it still returns any min cut $(S^*, \overline{S^*})$ with probability at least $1/{n \choose 2}$. (Hence, edge-weighted graphs also have at most ${n \choose 2}$ min cuts.) | All other edges connecting either u {\displaystyle u} or v {\displaystyle v} are "reattached" to the merged node, effectively producing a multigraph. Karger's basic algorithm iteratively contracts randomly chosen edges until only two nodes remain; those nodes represent a cut in the original graph. By iterating this bas... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
You have $1$ Euro and your goal is to exchange it to Swiss francs during the next two consecutive days. The exchange rate is an arbitrary function from days to real numbers from the interval $[1,W^2]$, where $W\geq 1$ is known to the algorithm. More precisely, at day $1$, you learn the exchange rate $x_1 \in [1,W^2]$,... | (Example where E ( y i ) {\displaystyle \mathbb {E} (y_{i})} converges) You have a fair coin and are repeatedly tossing it. Each time, before it is tossed, you can choose to stop tossing it and get paid (in dollars, say) the average number of heads observed. You wish to maximise the amount you get paid by choosing a st... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
You have $1$ Euro and your goal is to exchange it to Swiss francs during the next two consecutive days. The exchange rate is an arbitrary function from days to real numbers from the interval $[1,W^2]$, where $W\geq 1$ is known to the algorithm. More precisely, at day $1$, you learn the exchange rate $x_1 \in [1,W^2]$,... | A different approach to Siegel's paradox is proposed by K. Mallahi-Karai and P. Safari, where they show that the only possible way to avoid making risk-less money in such future-based currency exchanges is to settle on the (weighted) geometric mean of the future exchange rates, or more generally a product of the weight... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
You have $1$ Euro and your goal is to exchange it to Swiss francs during the next two consecutive days. The exchange rate is an arbitrary function from days to real numbers from the interval $[1,W^2]$, where $W\geq 1$ is known to the algorithm. More precisely, at day $1$, you learn the exchange rate $x_1 \in [1,W^2]$,... | One way to deal with the foreign exchange risk is to engage in a forward transaction. In this transaction, money does not actually change hands until some agreed upon future date. A buyer and seller agree on an exchange rate for any date in the future, and the transaction occurs on that date, regardless of what the mar... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
You have $1$ Euro and your goal is to exchange it to Swiss francs during the next two consecutive days. The exchange rate is an arbitrary function from days to real numbers from the interval $[1,W^2]$, where $W\geq 1$ is known to the algorithm. More precisely, at day $1$, you learn the exchange rate $x_1 \in [1,W^2]$,... | A different approach to Siegel's paradox is proposed by K. Mallahi-Karai and P. Safari, where they show that the only possible way to avoid making risk-less money in such future-based currency exchanges is to settle on the (weighted) geometric mean of the future exchange rates, or more generally a product of the weight... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
& \multicolumn{3}{c}{ extbf{ProofWriter}} & \multicolumn{3}{c}{ extbf{CLUTRR-SG}} \
\cmidrule(lr){2-4} \cmidrule(lr){5-7}
What does the following function implement?
1 a => b => (not a) (not b) fls | could belong to C l t ≥ {\displaystyle Cl_{t}^{\geq }} or the form: x {\displaystyle x\,\!} could belong to C l t ≤ {\displaystyle Cl_{t}^{\leq }} . Finally, approximate rules has the syntax: if f ( x , q 1 ) ≥ r 1 {\displaystyle f(x,q_{1})\geq r_{1}\,\!} | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
& \multicolumn{3}{c}{ extbf{ProofWriter}} & \multicolumn{3}{c}{ extbf{CLUTRR-SG}} \
\cmidrule(lr){2-4} \cmidrule(lr){5-7}
What does the following function implement?
1 a => b => (not a) (not b) fls | For example, defining exp ( A ) = I + A + 1 2 ! A 2 + 1 3 ! A 3 + ⋯ {\textstyle \exp(A)=I+A+{\frac {1}{2! | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Let $y_1, y_2, \ldots, y_n$ be uniform random bits. For each non-empty subset $S\subseteq \{1,2, \ldots, n\}$, define $X_S = \oplus_{i\in S}\:y_i$. Show that the bits $\{X_S: \emptyset \neq S\subseteq \{1,2, \ldots, n\} \}$ are pairwise independent. This shows how to stretch $n$ truly random bits to $2^n-1$ pairwise in... | Assume that the least significant set bit of x − y {\displaystyle x-y} appears on position w − c {\displaystyle w-c} . Since a {\displaystyle a} is a random odd integer and odd integers have inverses in the ring Z 2 w {\displaystyle Z_{2^{w}}} , it follows that a ( x − y ) mod 2 w {\displaystyle a(x-y){\bmod {2}}^{w}} ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Let $y_1, y_2, \ldots, y_n$ be uniform random bits. For each non-empty subset $S\subseteq \{1,2, \ldots, n\}$, define $X_S = \oplus_{i\in S}\:y_i$. Show that the bits $\{X_S: \emptyset \neq S\subseteq \{1,2, \ldots, n\} \}$ are pairwise independent. This shows how to stretch $n$ truly random bits to $2^n-1$ pairwise in... | A finite set of n {\displaystyle n} random variables { X 1 , … , X n } {\displaystyle \{X_{1},\ldots ,X_{n}\}} is pairwise independent if and only if every pair of random variables is independent. Even if the set of random variables is pairwise independent, it is not necessarily mutually independent as defined next. A ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
In this problem we are going to formally analyze the important median trick. Suppose that we have a streaming algorithm for distinct elements that outputs an estimate $\hat d$ of the number $d$ of distinct elements such that \begin{align*} \Pr[\hat d > 3d] \leq 47 \% \qquad \mbox{and} \qquad \Pr[\hat d < d/3] \leq 47... | With the resulting sample size, the expected bucket size and especially the probability of a bucket exceeding a certain size can be estimated. The following will show that for an oversampling factor of S ∈ Θ ( log n ϵ 2 ) {\displaystyle S\in \Theta \left({\dfrac {\log n}{\epsilon ^{2}}}\right)} the probability that n... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
In this problem we are going to formally analyze the important median trick. Suppose that we have a streaming algorithm for distinct elements that outputs an estimate $\hat d$ of the number $d$ of distinct elements such that \begin{align*} \Pr[\hat d > 3d] \leq 47 \% \qquad \mbox{and} \qquad \Pr[\hat d < d/3] \leq 47... | By Yao's principle, it also applies to the expected number of comparisons for a randomized algorithm on its worst-case input. For deterministic algorithms, it has been shown that selecting the k {\displaystyle k} th element requires ( 1 + H ( k / n ) ) n + Ω ( n ) {\displaystyle {\bigl (}1+H(k/n){\bigr )}n+\Omega ({\sq... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Recall the Manhattan distance function that we saw in class: for any $d$-dimensional Boolean vectors $p,q \in \{0,1\}^d$, the Manhattan distance is defined by \begin{align*} \dist(p,q) = \|p-q\|_1 = |\{i: p_i \neq q_i\}|\,. \end{align*} Design a locality sensitive hash (LSH) family $\mathcal{H}$ of functions $h: \{0,1\... | As a result, the statistical distance to a uniform family is O ( m / p ) {\displaystyle O(m/p)} , which becomes negligible when p ≫ m {\displaystyle p\gg m} . The family of simpler hash functions h a ( x ) = ( a x mod p ) mod m {\displaystyle h_{a}(x)=(ax~{\bmod {~}}p)~{\bmod {~}}m} is only approximately universal: Pr ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Recall the Manhattan distance function that we saw in class: for any $d$-dimensional Boolean vectors $p,q \in \{0,1\}^d$, the Manhattan distance is defined by \begin{align*} \dist(p,q) = \|p-q\|_1 = |\{i: p_i \neq q_i\}|\,. \end{align*} Design a locality sensitive hash (LSH) family $\mathcal{H}$ of functions $h: \{0,1\... | A locality-preserving hash is a hash function f that maps points in a metric space M = ( M , d ) {\displaystyle {\mathcal {M}}=(M,d)} to a scalar value such that d ( p , q ) < d ( q , r ) ⇒ | f ( p ) − f ( q ) | < | f ( q ) − f ( r ) | {\displaystyle d(p,q) | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Given the following classes:
• class Pair[+U, +V]
• class Iterable[+U]
• class Map[U, +V] extends Iterable[Pair[U, V]]
Recall that + means covariance, - means contravariance and no annotation means invariance (i.e. neither
covariance nor contravariance).
Consider also the following typing relationships for A, B, X, and... | Subtyping and inheritance are independent (orthogonal) relationships. They may coincide, but none is a special case of the other. In other words, between two types S and T, all combinations of subtyping and inheritance are possible: S is neither a subtype nor a derived type of T S is a subtype but is not a derived type... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Given the following classes:
• class Pair[+U, +V]
• class Iterable[+U]
• class Map[U, +V] extends Iterable[Pair[U, V]]
Recall that + means covariance, - means contravariance and no annotation means invariance (i.e. neither
covariance nor contravariance).
Consider also the following typing relationships for A, B, X, and... | In languages with subtyping, the compatibility relation is more complex: If B is a subtype of A, then a value of type B can be used in a context where one of type A is expected (covariant), even if the reverse is not true. Like equivalence, the subtype relation is defined differently for each programming language, with... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Design and analyze a polynomial-time algorithm for the following problem: \begin{center} \begin{boxedminipage}[t]{0.83\textwidth} \begin{description} \item[Input:] a vertex set $V$. \item[Output:] vertex subsets $S_1, S_2, \ldots, S_\ell \subseteq V$ with the following property:\\[2mm] For every set of edges $E\subs... | Given an undirected graph G = (V, E) with an assignment of weights to the edges w: E → N and an integer k ∈ { 2 , 3 , … , | V | } , {\displaystyle k\in \{2,3,\ldots ,|V|\},} partition V into k disjoint sets F = { C 1 , C 2 , … , C k } {\displaystyle F=\{C_{1},C_{2},\ldots ,C_{k}\}} while minimizing ∑ i = 1 k − 1 ∑ j = ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Design and analyze a polynomial-time algorithm for the following problem: \begin{center} \begin{boxedminipage}[t]{0.83\textwidth} \begin{description} \item[Input:] a vertex set $V$. \item[Output:] vertex subsets $S_1, S_2, \ldots, S_\ell \subseteq V$ with the following property:\\[2mm] For every set of edges $E\subs... | An exhaustive search algorithm can solve the problem in time 2knO(1), where k is the size of the vertex cover. Vertex cover is therefore fixed-parameter tractable, and if we are only interested in small k, we can solve the problem in polynomial time. One algorithmic technique that works here is called bounded search tr... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Design a polynomial-time algorithm for the matroid matching problem: \begin{description} \item[Input:] A bipartite graph $G=(A \cup B, E)$ and two matroids $\mathcal{M}_A = (A, \mathcal{I}_A)$, $\mathcal{M}_B = (B, \mathcal{I}_B)$. \item[Output:] A matching $M \subseteq E$ of maximum cardinality satisfying: \begin{enum... | In combinatorial optimization, the matroid parity problem is a problem of finding the largest independent set of paired elements in a matroid. The problem was formulated by Lawler (1976) as a common generalization of graph matching and matroid intersection. It is also known as polymatroid matching, or the matchoid prob... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Design a polynomial-time algorithm for the matroid matching problem: \begin{description} \item[Input:] A bipartite graph $G=(A \cup B, E)$ and two matroids $\mathcal{M}_A = (A, \mathcal{I}_A)$, $\mathcal{M}_B = (B, \mathcal{I}_B)$. \item[Output:] A matching $M \subseteq E$ of maximum cardinality satisfying: \begin{enum... | Many other optimization problems can be formulated as linear matroid parity problems, and solved in polynomial time using this formulation. Graph matching A maximum matching in a graph is a subset of edges, no two sharing an endpoint, that is as large as possible. It can be formulated as a matroid parity problem in a p... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
A multiset is an unordered collection where elements can appear multiple times. We will represent a multiset of Char elements as a function from Char to Int: the function returns 0 for any Char argument that is not in the multiset, and the (positive) number of times it appears otherwise: type Multiset = Char => Int The... | A multiset may be formally defined as an ordered pair (A, m) where A is the underlying set of the multiset, formed from its distinct elements, and m: A → Z + {\displaystyle m\colon A\to \mathbb {Z} ^{+}} is a function from A to the set of positive integers, giving the multiplicity – that is, the number of occurrences –... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
A multiset is an unordered collection where elements can appear multiple times. We will represent a multiset of Char elements as a function from Char to Int: the function returns 0 for any Char argument that is not in the multiset, and the (positive) number of times it appears otherwise: type Multiset = Char => Int The... | In mathematics, a multiset (or bag, or mset) is a modification of the concept of a set that, unlike a set, allows for multiple instances for each of its elements. The number of instances given for each element is called the multiplicity of that element in the multiset. As a consequence, an infinite number of multisets ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
A monad M is a parametric type M[T] with two operations, flatMap and unit: extension [T, U](m: M[T]) def flatMap(f: T => M[U]): M[U] def unit[T](x: T): M[T] To qualify as a monad, a type has to satisfy the three following laws for all m: M[T], x: T, f: T => M[U] and g: U => M[V]: (Associativity) m.flatMap(f).flatMap(g)... | The more common definition for a monad in functional programming, used in the above example, is actually based on a Kleisli triple ⟨T, η, μ⟩ rather than category theory's standard definition. The two constructs turn out to be mathematically equivalent, however, so either definition will yield a valid monad. Given any w... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
A monad M is a parametric type M[T] with two operations, flatMap and unit: extension [T, U](m: M[T]) def flatMap(f: T => M[U]): M[U] def unit[T](x: T): M[T] To qualify as a monad, a type has to satisfy the three following laws for all m: M[T], x: T, f: T => M[U] and g: U => M[V]: (Associativity) m.flatMap(f).flatMap(g)... | In homological algebra, a monad is a 3-term complex A → B → Cof objects in some abelian category whose middle term B is projective and whose first map A → B is injective and whose second map B → C is surjective. Equivalently, a monad is a projective object together with a 3-step filtration (B ⊃ ker(B → C) ⊃ im(A → B)).... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
In the maximum directed cut problem we are given as input a directed graph $G = (V, A)$. Each arc $(i, j)\in A$ has a nonnegative weight $w_{ij} \geq 0$. The goal is to partition $V$ into two sets $U$ and $W = V \setminus U$ so as to maximize the total weight of the arcs going from $U$ to $W$ (that is, arcs $(i, j)$ w... | We already know that (2,1) cut is the minimum bisection problem and it is NP-complete. Next, we assess a 3-partition problem wherein n = 3k, which is also bounded in polynomial time. Now, if we assume that we have a finite approximation algorithm for (k, 1)-balanced partition, then, either the 3-partition instance can ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
In the maximum directed cut problem we are given as input a directed graph $G = (V, A)$. Each arc $(i, j)\in A$ has a nonnegative weight $w_{ij} \geq 0$. The goal is to partition $V$ into two sets $U$ and $W = V \setminus U$ so as to maximize the total weight of the arcs going from $U$ to $W$ (that is, arcs $(i, j)$ w... | One wants a subset S of the vertex set such that the number of edges between S and the complementary subset is as large as possible. Equivalently, one wants a bipartite subgraph of the graph with as many edges as possible. There is a more general version of the problem called weighted max-cut, where each edge is associ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
In a game of Othello (also known as Reversi in French-speaking countries), when a player puts a token on a square of the board, we have to look in all directions around that square to find which squares should be “flipped” (i.e., be stolen from the opponent). We implement this in a method computeFlips, taking the posit... | Then, the initial position can be described in combinatorial game theory notation as { ( A 1 , A 2 ) , ( B 1 , B 2 ) , … | ( A 1 , B 1 ) , ( A 2 , B 2 ) , … } . {\displaystyle \{(\mathrm {A} 1,\mathrm {A} 2),(\mathrm {B} 1,\mathrm {B} 2),\dots |(\mathrm {A} 1,\mathrm {B} 1),(\mathrm {A} 2,\mathrm {B} 2),\dots \}.} In s... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
In a game of Othello (also known as Reversi in French-speaking countries), when a player puts a token on a square of the board, we have to look in all directions around that square to find which squares should be “flipped” (i.e., be stolen from the opponent). We implement this in a method computeFlips, taking the posit... | The game subtract-a-square can also be played with multiple numbers. At each turn the player to make a move first selects one of the numbers, and then subtracts a square from it. Such a 'sum of normal games' can be analysed using the Sprague–Grundy theorem. This theorem states that each position in the game subtract-a-... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
In this problem we are going to investigate the linear programming relaxation of a classical scheduling problem. In the considered problem, we are given a set $M$ of $m$ machines and a set $J$ of $n$ jobs. Each job $j\in J$ has a processing time $p_j > 0$ and can be processed on a subset $N(j) \subseteq M$ of the machi... | A natural way to formulate the problem as a linear program is called the Lenstra–Shmoys–Tardos linear program (LST LP). For each machine i and job j, define a variable z i , j {\displaystyle z_{i,j}} , which equals 1 iff machine i processes job j, and 0 otherwise. Then, the LP constraints are: ∑ i = 1 m z i , j = 1 {\d... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
In this problem we are going to investigate the linear programming relaxation of a classical scheduling problem. In the considered problem, we are given a set $M$ of $m$ machines and a set $J$ of $n$ jobs. Each job $j\in J$ has a processing time $p_j > 0$ and can be processed on a subset $N(j) \subseteq M$ of the machi... | Using the technique of Linear programming relaxation, it is possible to approximate the optimal scheduling with slightly better approximation factors. The approximation ratio of the first such algorithm is asymptotically 2 when k is large, but when k=2 the algorithm achieves an approximation ratio of 5/3. The approxima... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider the min-cost perfect matching problem on a bipartite graph $G=(A \cup B, E)$ with costs $c: E \rightarrow \mathbb{R}$. Recall from the lecture that the dual linear program is \begin{align*} \text{Maximize} \quad & \sum_{a\in A} u_a + \sum_{b\in B} v_b\\ \text{Subject to} \quad &u_a + v_b \leq c(\{a,b\}) \qqu... | Therefore, by the LP duality theorem, both programs have the same solution. This fact is true not only in bipartite graphs but in arbitrary graphs:In any graph, the largest size of a fractional matching equals the smallest size of a fractional vertex cover.What makes bipartite graphs special is that, in bipartite graph... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider the min-cost perfect matching problem on a bipartite graph $G=(A \cup B, E)$ with costs $c: E \rightarrow \mathbb{R}$. Recall from the lecture that the dual linear program is \begin{align*} \text{Maximize} \quad & \sum_{a\in A} u_a + \sum_{b\in B} v_b\\ \text{Subject to} \quad &u_a + v_b \leq c(\{a,b\}) \qqu... | The polytope described by the linear program upper bounding the sum of edges taken per vertex is integral in the case of bipartite graphs, that is, it exactly describes the matching polytope, while for general graphs it is non-integral. Hence, for bipartite graphs, it suffices to solve the corresponding linear program ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
You are given three classes (Student, Exam and Course which are defined below) and the method generatePassedExams, which from a given list of students and a list of courses, generates a list of students and all their successfully passed courses together with the corresponding grade. A course is considered as successful... | An example of a list comprehension using multiple generators: | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
You are given three classes (Student, Exam and Course which are defined below) and the method generatePassedExams, which from a given list of students and a list of courses, generates a list of students and all their successfully passed courses together with the corresponding grade. A course is considered as successful... | Python uses the following syntax to express list comprehensions over finite lists: A generator expression may be used in Python versions >= 2.4 which gives lazy evaluation over its input, and can be used with generators to iterate over 'infinite' input such as the count generator function which returns successive integ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider an undirected graph $G=(V,E)$ and let $s\neq t\in V$. In the minimum (unweighted) $s,t$-cut problem, we wish to find a set $S\subseteq V$ such that $s\in S$, $t\not \in S$ and the number of edges crossing the cut is minimized. We shall use a linear program to solve this problem. Let ${P}$ be the set of all pat... | For weighted graphs with positive edge weights w: E → R + {\displaystyle w\colon E\rightarrow \mathbf {R} ^{+}} the weight of the cut is the sum of the weights of edges between vertices in each part w ( S , T ) = ∑ u v ∈ E: u ∈ S , v ∈ T w ( u v ) , {\displaystyle w(S,T)=\sum _{uv\in E\colon u\in S,v\in T}w(uv)\,,} whi... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider an undirected graph $G=(V,E)$ and let $s\neq t\in V$. In the minimum (unweighted) $s,t$-cut problem, we wish to find a set $S\subseteq V$ such that $s\in S$, $t\not \in S$ and the number of edges crossing the cut is minimized. We shall use a linear program to solve this problem. Let ${P}$ be the set of all pat... | The cutting-plane method for solving 0–1 integer programs, first introduced for the traveling salesman problem by Dantzig, Fulkerson & Johnson (1954) and generalized to other integer programs by Gomory (1958), takes advantage of this multiplicity of possible relaxations by finding a sequence of relaxations that more ti... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider the following quadratic programming relaxation of the Max Cut problem on $G=(V,E)$: \begin{align*} \textbf{maximize} \hspace{0.8cm} & \sum_{\{i,j\} \in E} (1-x_i)x_j + x_i (1-x_j) \\ \textbf{subject to}\hspace{0.8cm} & x_i \in [0,1] ~ ~ \forall i\in V \end{align*} Show that the optimal value of the quadratic r... | However, Goemans and Williamson observed a general three-step procedure for attacking this sort of problem: Relax the integer quadratic program into an SDP. Solve the SDP (to within an arbitrarily small additive error ϵ {\displaystyle \epsilon } ). Round the SDP solution to obtain an approximate solution to the origina... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider the following quadratic programming relaxation of the Max Cut problem on $G=(V,E)$: \begin{align*} \textbf{maximize} \hspace{0.8cm} & \sum_{\{i,j\} \in E} (1-x_i)x_j + x_i (1-x_j) \\ \textbf{subject to}\hspace{0.8cm} & x_i \in [0,1] ~ ~ \forall i\in V \end{align*} Show that the optimal value of the quadratic r... | When the algorithm terminates, at least half of the edges incident to every vertex belong to the cut, for otherwise moving the vertex would improve the cut. Therefore, the cut includes at least | E | / 2 {\displaystyle |E|/2} edges. The polynomial-time approximation algorithm for Max-Cut with the best known approximati... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Implement a function that takes a lists ls as argument and returns the length of the longest contiguous sequence of repeated elements in that list. For this second question, you are required to use foldLeft in your solution, and your solution should not be recursive. For example: longest(List(1, 2, 2, 5, 5, 5, 1, 1, 1)... | One find LIS by using the fact: Number of such sequences corresponds to LIS, where the actually LIS sequence is found by taking one element from each sequence. Note that 1 ≤ l ≤ i + 1 , {\displaystyle 1\leq l\leq i+1,} because l ≥ 1 {\displaystyle l\geq 1} represents the length of the increasing subsequence, and k ≥ 0 ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Implement a function that takes a lists ls as argument and returns the length of the longest contiguous sequence of repeated elements in that list. For this second question, you are required to use foldLeft in your solution, and your solution should not be recursive. For example: longest(List(1, 2, 2, 5, 5, 5, 1, 1, 1)... | As another, more formal example, consider the following property of lists: EQ: len ( L + + M ) = len ( L ) + len ( M ) {\displaystyle {\text{EQ:}}\quad \operatorname {len} (L+\!+\ M)=\operatorname {len} (L)+\operatorname {len} (M)} Here ++ denotes the list concatenation operation, len() the list length, and L and... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Implement a function that inserts a given element elem into a sorted (in ascending order) list list . The resulting list should also be sorted in ascending order. Implement the function recursively. def insert (elem: Int, list: List[Int]): List[Int] = ??? | Insertion sort for int list (ascending) can be expressed concisely as follows: | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Implement a function that inserts a given element elem into a sorted (in ascending order) list list . The resulting list should also be sorted in ascending order. Implement the function recursively. def insert (elem: Int, list: List[Int]): List[Int] = ??? | Insertion sort is a simple sorting algorithm that is relatively efficient for small lists and mostly sorted lists, and is often used as part of more sophisticated algorithms. It works by taking elements from the list one by one and inserting them in their correct position into a new sorted list similar to how we put mo... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
In class, we saw Karger's beautiful randomized algorithm for finding a min-cut in an undirected graph $G=(V,E)$ with $n = |V|$ vertices. Each iteration of Karger's algorithm can be implemented in time $O(n^2)$, and if repeated $\Theta(n^2 \log n)$ times, Karger's algorithm returns a min-cut with probability at least $1... | To determine a min-cut, one has to touch every edge in the graph at least once, which is Θ ( n 2 ) {\displaystyle \Theta (n^{2})} time in a dense graph. The Karger–Stein's min-cut algorithm takes the running time of O ( n 2 ln O ( 1 ) n ) {\displaystyle O(n^{2}\ln ^{O(1)}n)} , which is very close to that. == Referenc... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
In class, we saw Karger's beautiful randomized algorithm for finding a min-cut in an undirected graph $G=(V,E)$ with $n = |V|$ vertices. Each iteration of Karger's algorithm can be implemented in time $O(n^2)$, and if repeated $\Theta(n^2 \log n)$ times, Karger's algorithm returns a min-cut with probability at least $1... | In computer science and graph theory, Karger's algorithm is a randomized algorithm to compute a minimum cut of a connected graph. It was invented by David Karger and first published in 1993.The idea of the algorithm is based on the concept of contraction of an edge ( u , v ) {\displaystyle (u,v)} in an undirected graph... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Use the integrality of the bipartite perfect matching polytope (as proved in class) to show the following classical result: \begin{itemize} \item[] The edge set of a $k$-regular bipartite graph $G=(A\cup B, E)$ can in polynomial time be partitioned into $k$ disjoint perfect matchings. \end{itemize} \noindent A graph is... | The polytope described by the linear program upper bounding the sum of edges taken per vertex is integral in the case of bipartite graphs, that is, it exactly describes the matching polytope, while for general graphs it is non-integral. Hence, for bipartite graphs, it suffices to solve the corresponding linear program ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Use the integrality of the bipartite perfect matching polytope (as proved in class) to show the following classical result: \begin{itemize} \item[] The edge set of a $k$-regular bipartite graph $G=(A\cup B, E)$ can in polynomial time be partitioned into $k$ disjoint perfect matchings. \end{itemize} \noindent A graph is... | Let G = ( X , Y , E ) {\displaystyle G=(X,Y,E)} be a finite bipartite graph with bipartite sets X {\displaystyle X} and Y {\displaystyle Y} and edge set E {\displaystyle E} . An X {\displaystyle X} -perfect matching (also called an X {\displaystyle X} -saturating matching) is a matching, a set of disjoint edges, which ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Homer, Marge, and Lisa Simpson have decided to go for a hike in the beautiful Swiss Alps. Homer has greatly surpassed Marge's expectations and carefully prepared to bring $n$ items whose total size equals the capacity of his and his wife Marge's two knapsacks. Lisa does not carry a knapsack due to her young age. More ... | The most common problem being solved is the 0-1 knapsack problem, which restricts the number x i {\displaystyle x_{i}} of copies of each kind of item to zero or one. Given a set of n {\displaystyle n} items numbered from 1 up to n {\displaystyle n} , each with a weight w i {\displaystyle w_{i}} and a value v i {\displa... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Homer, Marge, and Lisa Simpson have decided to go for a hike in the beautiful Swiss Alps. Homer has greatly surpassed Marge's expectations and carefully prepared to bring $n$ items whose total size equals the capacity of his and his wife Marge's two knapsacks. Lisa does not carry a knapsack due to her young age. More ... | The unbounded knapsack problem (UKP) places no restriction on the number of copies of each kind of item. Besides, here we assume that x i > 0 {\displaystyle x_{i}>0} m = max ( ∑ i = 1 n v i x i ) {\displaystyle m=\max \left(\sum _{i=1}^{n}v_{i}x_{i}\right)} subject to ∑ i = 1 n w i x i ≤ w ′ {\displaystyle \sum _{i=1}... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Devise an algorithm for the following graph orientation problem: \begin{description} \item[Input:] An undirected graph $G = (V,E)$ and capacities $k : V \rightarrow \mathbb{Z}$ for each vertex. \item[Output:] If possible, an orientation of $G$ such that each vertex $v\in V$ has in-degree at most $k(v)$. \end{descriptio... | In graph theory, an orientation of an undirected graph is an assignment of a direction to each edge, turning the initial graph into a directed graph. | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Devise an algorithm for the following graph orientation problem: \begin{description} \item[Input:] An undirected graph $G = (V,E)$ and capacities $k : V \rightarrow \mathbb{Z}$ for each vertex. \item[Output:] If possible, an orientation of $G$ such that each vertex $v\in V$ has in-degree at most $k(v)$. \end{descriptio... | Another interesting connection concerns orientations of graphs. An orientation of an undirected graph G is any directed graph obtained by choosing one of the two possible orientations for each edge. An example of an orientation of the complete graph Kk is the transitive tournament T→k with vertices 1,2,…,k and arcs fro... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider the following case class definitions: case class Node(id: Int) case class Edge(from: Node, to: Node) Let us represent a directed graph G as the list of all its edges (of type List[Edge]). We are interested in computing the set of all nodes reachable in exactly n steps from a set of initial nodes. Write a reach... | For a directed graph G = ( V , E ) {\displaystyle G=(V,E)} , with vertex set V {\displaystyle V} and edge set E {\displaystyle E} , the reachability relation of G {\displaystyle G} is the transitive closure of E {\displaystyle E} , which is to say the set of all ordered pairs ( s , t ) {\displaystyle (s,t)} of vertices... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider the following case class definitions: case class Node(id: Int) case class Edge(from: Node, to: Node) Let us represent a directed graph G as the list of all its edges (of type List[Edge]). We are interested in computing the set of all nodes reachable in exactly n steps from a set of initial nodes. Write a reach... | In graph theory, reachability refers to the ability to get from one vertex to another within a graph. A vertex s {\displaystyle s} can reach a vertex t {\displaystyle t} (and t {\displaystyle t} is reachable from s {\displaystyle s} ) if there exists a sequence of adjacent vertices (i.e. a walk) which starts with s {\d... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider a bipartite graph $G=(V,E)$ where $V$ is partitioned into $A$ and $B$. Let $(A, \mathcal{I})$ be the matroid with ground set $A$ and \begin{align*} \mathcal{I} = \{ A' \subseteq A: \mbox{ $G$ has a matching in which every vertex of $A'$ is matched}\}\,. \end{align*} Recall that we say that a vertex is matched ... | Let G = (U,V,E) be a bipartite graph. One may define a partition matroid MU on the ground set E, in which a set of edges is independent if no two of the edges have the same endpoint in U. Similarly one may define a matroid MV in which a set of edges is independent if no two of the edges have the same endpoint in V. Any... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider a bipartite graph $G=(V,E)$ where $V$ is partitioned into $A$ and $B$. Let $(A, \mathcal{I})$ be the matroid with ground set $A$ and \begin{align*} \mathcal{I} = \{ A' \subseteq A: \mbox{ $G$ has a matching in which every vertex of $A'$ is matched}\}\,. \end{align*} Recall that we say that a vertex is matched ... | A maximum matching in a graph is a set of edges that is as large as possible subject to the condition that no two edges share an endpoint. In a bipartite graph with bipartition ( U , V ) {\displaystyle (U,V)} , the sets of edges satisfying the condition that no two edges share an endpoint in U {\displaystyle U} are the... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Suppose we use the Simplex method to solve the following linear program: \begin{align*} \textbf{maximize} \hspace{0.8cm} & \hspace{0.4cm}4x_1 - 6x_2 + 4x_3 \\ \textbf{subject to}\hspace{0.6cm} & x_1 - 3x_2 + x_3 + s_1 = 1 \\ \hspace{0.8cm} & \hspace{1.90cm}x_1 + s_2 = 8 \\ \hspace{0.8cm} & \hspace{0.65cm} 3x_2 + 2... | Let a linear program be given by a canonical tableau. The simplex algorithm proceeds by performing successive pivot operations each of which give an improved basic feasible solution; the choice of pivot element at each step is largely determined by the requirement that this pivot improves the solution. | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Suppose we use the Simplex method to solve the following linear program: \begin{align*} \textbf{maximize} \hspace{0.8cm} & \hspace{0.4cm}4x_1 - 6x_2 + 4x_3 \\ \textbf{subject to}\hspace{0.6cm} & x_1 - 3x_2 + x_3 + s_1 = 1 \\ \hspace{0.8cm} & \hspace{1.90cm}x_1 + s_2 = 8 \\ \hspace{0.8cm} & \hspace{0.65cm} 3x_2 + 2... | Using the simplex method to solve a linear program produces a set of equations of the form x i + ∑ j a ¯ i , j x j = b ¯ i {\displaystyle x_{i}+\sum _{j}{\bar {a}}_{i,j}x_{j}={\bar {b}}_{i}} where xi is a basic variable and the xj's are the nonbasic variables (i.e. the basic solution which is an optimal solution to the... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Professor Ueli von Gruy\`{e}res has worked intensely throughout his career to get a good estimator of the yearly consumption of cheese in Switzerland. Recently, he had a true breakthrough. He was able to design an incredibly efficient randomized algorithm \Alg that outputs a random value $X$ satisfying \begin{align*} \... | A way simpler possibility comes to mind and it is just drawing a straight line between two points and coming up with all the relevant data graphically. However, even though it is clearly seen in the paper that the income perceived is rising by 100 francs per sample family, the food expenditure is definitely not decreas... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Professor Ueli von Gruy\`{e}res has worked intensely throughout his career to get a good estimator of the yearly consumption of cheese in Switzerland. Recently, he had a true breakthrough. He was able to design an incredibly efficient randomized algorithm \Alg that outputs a random value $X$ satisfying \begin{align*} \... | A way simpler possibility comes to mind and it is just drawing a straight line between two points and coming up with all the relevant data graphically. However, even though it is clearly seen in the paper that the income perceived is rising by 100 francs per sample family, the food expenditure is definitely not decreas... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Let $A \in \mathbb{R}^{m\times n}$, $b\in \mathbb{R}^m$ and $c\in \mathbb{R}^n$. Consider the following linear program with $n$ variables: \begin{align*} \textbf{maximize} \hspace{0.8cm} & c^Tx \\ \textbf{subject to}\hspace{0.8cm} & Ax =b \\ \hspace{0.8cm} & x \geq 0 \end{align*} Show that any extreme point $x^*$ has a... | It can be shown that for a linear program in standard form, if the objective function has a maximum value on the feasible region, then it has this value on (at least) one of the extreme points. This in itself reduces the problem to a finite computation since there is a finite number of extreme points, but the number of... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Let $A \in \mathbb{R}^{m\times n}$, $b\in \mathbb{R}^m$ and $c\in \mathbb{R}^n$. Consider the following linear program with $n$ variables: \begin{align*} \textbf{maximize} \hspace{0.8cm} & c^Tx \\ \textbf{subject to}\hspace{0.8cm} & Ax =b \\ \hspace{0.8cm} & x \geq 0 \end{align*} Show that any extreme point $x^*$ has a... | 21, 502–505 (1970). On Bauer’s characterization of extreme points. Math. | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider the program below. Tick the correct answer. def fun(x: List[Int]) = if x.isEmpty then None else Some(x) val lists = List(List(1, 2, 3), List(), List(4, 5, 6)) for \t l <- lists \t v1 <- fun(l) \t v2 <- fun(v1) yield v2 | Instead of the Java "foreach" loops for looping through an iterator, Scala has for-expressions, which are similar to list comprehensions in languages such as Haskell, or a combination of list comprehensions and generator expressions in Python. For-expressions using the yield keyword allow a new collection to be generat... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider the program below. Tick the correct answer. def fun(x: List[Int]) = if x.isEmpty then None else Some(x) val lists = List(List(1, 2, 3), List(), List(4, 5, 6)) for \t l <- lists \t v1 <- fun(l) \t v2 <- fun(v1) yield v2 | Python uses the following syntax to express list comprehensions over finite lists: A generator expression may be used in Python versions >= 2.4 which gives lazy evaluation over its input, and can be used with generators to iterate over 'infinite' input such as the count generator function which returns successive integ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
The goal of the 4 following questions is to prove that the methods map and mapTr are equivalent. The
former is the version seen in class and is specified by the lemmas MapNil and MapCons. The later version
is a tail-recursive version and is specified by the lemmas MapTrNil and MapTrCons.
All lemmas on this page hold fo... | {\displaystyle l\in J_{2}.} Every map f ∈ ∏ J ∙ = def ∏ i ∈ I J i = J 1 × J 2 = K × L {\displaystyle f\in {\textstyle \prod }J_{\bullet }~{\stackrel {\scriptscriptstyle {\text{def}}}{=}}~{\textstyle \prod \limits _{i\in I}}J_{i}=J_{1}\times J_{2}=K\times L} can be bijectively identified with the pair ( f ( 1 ) , f ( 2 ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
The goal of the 4 following questions is to prove that the methods map and mapTr are equivalent. The
former is the version seen in class and is specified by the lemmas MapNil and MapCons. The later version
is a tail-recursive version and is specified by the lemmas MapTrNil and MapTrCons.
All lemmas on this page hold fo... | The maps between the kernels and the maps between the cokernels are induced in a natural manner by the given (horizontal) maps because of the diagram's commutativity. The exactness of the two induced sequences follows in a straightforward way from the exactness of the rows of the original diagram. The important stateme... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider the following definition of trees representing higher-order functions, as well as a recursive function
subst0.
1 enum Expr:
2 case C(c: BigInt)
3 case N(name: String)
4 case BinOp(op: BinOps, e1: Expr, e2: Expr)
5 case IfNonzero(cond: Expr, trueE: Expr, falseE: Expr)
6 case Call(fun: Expr, arg: Expr)
7 case Fu... | Informally, and using programming language jargon, a tree (xy) can be thought of as a function x applied to an argument y. When evaluated (i.e., when the function is "applied" to the argument), the tree "returns a value", i.e., transforms into another tree. The "function", "argument" and the "value" are either combinat... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider the following definition of trees representing higher-order functions, as well as a recursive function
subst0.
1 enum Expr:
2 case C(c: BigInt)
3 case N(name: String)
4 case BinOp(op: BinOps, e1: Expr, e2: Expr)
5 case IfNonzero(cond: Expr, trueE: Expr, falseE: Expr)
6 case Call(fun: Expr, arg: Expr)
7 case Fu... | (1, if n = 0; else n × ((Y G) (n−1)))) (2−1)))) 4 × (3 × (2 × (1, if 1 = 0; else 1 × ((Y G) (1−1))))) 4 × (3 × (2 × (1 × (G (Y G) (1−1))))) 4 × (3 × (2 × (1 × ((λn. (1, if n = 0; else n × ((Y G) (n−1)))) (1−1))))) 4 × (3 × (2 × (1 × (1, if 0 = 0; else 0 × ((Y G) (0−1)))))) 4 × (3 × (2 × (1 × (1)))) 24Every recursively ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider a data stream $\sigma=(a_1,\ldots, a_m)$, with $a_j\in [n]$ for every $j=1,\ldots, m$, where we let $[n]:=\{1, 2, \ldots, n\}$ to simplify notation. For $i\in [n]$ let $f_i$ denote the number of times element $i$ appeared in the stream $\sigma$. We say that a stream $\sigma$ is {\epsilonm approximately sparse... | Instance: A stream of elements x 1 , x 2 , … , x s {\displaystyle x_{1},x_{2},\ldots ,x_{s}} with repetitions, and an integer m {\displaystyle m} . Let n {\displaystyle n} be the number of distinct elements, namely n = | { x 1 , x 2 , … , x s } | {\displaystyle n=|\left\{{x_{1},x_{2},\ldots ,x_{s}}\right\}|} , and let ... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Consider a data stream $\sigma=(a_1,\ldots, a_m)$, with $a_j\in [n]$ for every $j=1,\ldots, m$, where we let $[n]:=\{1, 2, \ldots, n\}$ to simplify notation. For $i\in [n]$ let $f_i$ denote the number of times element $i$ appeared in the stream $\sigma$. We say that a stream $\sigma$ is {\epsilonm approximately sparse... | In the data stream model, the frequent elements problem is to output a set of elements that constitute more than some fixed fraction of the stream. A special case is the majority problem, which is to determine whether or not any value constitutes a majority of the stream. More formally, fix some positive constant c > 1... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Suppose you are using the Hedge algorithm to invest your money (in a good way) into $N$ different investments. Every day you see how well your investments go: for $i\in [N]$ you observe the change of each investment in percentages. For example, $\mbox{change(i) = 20\%}$ would mean that investment $i$ increased in valu... | So every day it multiplies its value once by (100% + r%). So if I hold the investment for n days, its value will have multiplied itself by this amount n times, making that value (100% + r%)n of what it was at the start – that is, (1 + r)n times what it was at the start. So to figure out how much I would need to start w... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Suppose you are using the Hedge algorithm to invest your money (in a good way) into $N$ different investments. Every day you see how well your investments go: for $i\in [N]$ you observe the change of each investment in percentages. For example, $\mbox{change(i) = 20\%}$ would mean that investment $i$ increased in valu... | The hedge algorithm is similar to the weighted majority algorithm. However, their exponential update rules are different. It is generally used to solve the problem of binary allocation in which we need to allocate different portion of resources into N different options. The loss with every option is available at the en... | https://www.kaggle.com/datasets/conjuring92/wiki-stem-corpus |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.