%ex2.3

\begin{enumerate}[label=(\alph*)]
	\item\textbf{Bag Union, defined to be the bag of tuples in which tuple t appears the sum of the
		numbers of times it appears in R and S, e.g. if tuple t occurs in R 3 times, and in S 4
		times, then it should occur in the bag union R and S 7 times.}\\
	
		\textbf{Map function:} for every tuple t in R and for every tuple t in
		S, produce the key-value pair (t,t);
		
		\textbf{Reduce function:} Receives input of the form (t; [t, t, …, t])\\
		outputs (t,t) k-times\\
		
	\item\textbf{Bag Difference, defined to be the bag of tuples in which the number of times a tuple
		t appears is equal to the number of times it appears in R minus the number of times it
		appears in S. A tuple that appears more times in S than in R does not appear in the
		difference, e.g. if tuple t occurs in R 4 times, and in S 3 times, then it should occur in
		the bag difference of R with S only once.}\\
	
		\textbf{Map function:} for every tuple t in R and for every tuple t in
		S, produce the key-value pair (t; ''R'') or (t; ''S''), respectively.
		
		\textbf{Reduce function:} Receives input of the form (t; [$x_{1}$,…,$x_{n}$]), where each $x_{i}$ is either the form of ''R'' or ''S''.\\
		Outputs (t,t) if the input contains ''R'' but not ''S''.\\
		Outputs nothing otherwise.
		
		\textbf{Alternative Reduce function:} Receives input of the form (t; [$x_{1}$,…,$x_{n}$]), where each $x_{i}$ is either the form of ''R'' or ''S''.\\
		Initialize a counter k = 0. For each ''R'' increment k. For each ''S'' decrement k.\\
		Outputs (t,t) k times, if k > 0.
\end{enumerate}
