edited by
100 views
0 votes
0 votes

Consider two $n \times 1$ vectors u and v, stored as tables  $\mathrm{U(ind, val)}$ and $\mathrm{V(ind, val)}$ with the same schema. A row $\left(i, u_{i}\right)$ of table $\mathrm{U}$ specifies that the $i$-th element of vector u has value $u_{i}$ (similarly for v, respectively). Only the non-zero entries of the vectors are stored in the corresponding tables. For example, if the vector u equals $(0,1,3,0,2,0)$, then it is represented in table $\mathrm{U}$ as:

ind val

2

3

5

1

3

2

Write a relational algebra expression or an $\text{SQL}$ query to compute the sum u $+$ v of the two vectors u and v. Explain your solution.

edited by

Please log in or register to answer this question.

Related questions

1 votes
1 votes
1 answer
1
0 votes
0 votes
0 answers
3
1 votes
1 votes
1 answer
4
admin asked Aug 8, 2022
424 views
Consider a stack machine where the only available workspace is a stack whose elements are unsigned integers. We will denote the configuration of the stack by a sequence. ...