The size of the intersection divided by the size of the union is used to determine how similar two papers are (each having unique words). For instance, if the documents are made up of integers, the similarity between 1, 5, 3 and 1, 7, 2, 3 is 0, 4, as the intersection and union have sizes of 2 and 5, respectively.We have a large collection of documents (each with a unique value and a corresponding ID), where the similarity is deemed to be "sparse": This means that there is a high likelihood of resemblance between any two randomly chosen papers. O. Create an algorithm that provides a list of document ID pairings together with the corresponding similarity. Only the pairings with similarity larger than 0 should be printed.Empty documents should not be printed at all. For simplicity, you may assume each document is represented as an array of distinct integers. EXAMPLE Input: 13: {14, 15, 100, 9, 3} 16: {32, 1, 9, 3, 5} 19: {15, 29, 2, 6, 8, 7} 24: {7, 10} Output: ID1, ID2 13, 19 13, 16 19, 24 SIMILARITY 0.1 0.25 0.14285714285714285
The size of the intersection divided by the size of the union is used to determine how similar two papers are (each having unique words). For instance, if the documents are made up of integers, the similarity between 1, 5, 3 and 1, 7, 2, 3 is 0, 4, as the intersection and union have sizes of 2 and 5, respectively.We have a large collection of documents (each with a unique value and a corresponding ID), where the similarity is deemed to be "sparse": This means that there is a high likelihood of resemblance between any two randomly chosen papers. O. Create an
simplicity, you may assume each document is represented as an array of distinct integers.
EXAMPLE
Input:
13: {14, 15, 100, 9, 3}
16: {32, 1, 9, 3, 5}
19: {15, 29, 2, 6, 8, 7}
24: {7, 10}
Output:
ID1, ID2
13, 19
13, 16
19, 24
SIMILARITY
0.1
0.25
0.14285714285714285
Step by step
Solved in 2 steps with 2 images