(Solved): B. Cosine Similarity (cos Sim) Is A Commonly Used Similarity Metric That Measures How Similar Two Ve ...

b. Cosine similarity (cos sim) is a commonly used similarity metric that measures how similar two vectors (arrays) of numbers are. The equation for cosine similarity is given by sim(A,B) = AB=Lj=14:BE B) ||18| 12, 47°E_, B? where A; and B; are components of vector A and B respectively. Write pseudocode to calculate cosine similarity of two vectors A and B. it should take two arrays of numbers, A and B, as arguments and return a single value, their cosine similarity. Write pseudo code and please add comments explaining the steps. b. We have n unique items. For i = 1,2,3,...,n, each item has a weight w;> 0 and value v;> 0. Write a greedy algorithm to find the maximum value of items that can be carried in a knapsack with a maximum weight capacity of W. An item may be broken into pieces and only a fraction put into the knapsack. It should take an array of weights, an array of item values and the weight limit of the knapsack as input. The array of weights and items are ordered such that w; corresponds to the same item as v. Write a C program. Please add comments explaining the steps.