From 58402f37a6f41a2a40fda0f4583d4e19d8bc7c5e Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Wed, 31 Jan 2024 04:03:41 -0500 Subject: [PATCH] do not use variable length arrays --- hws/03_amazon_prime/recommendation.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hws/03_amazon_prime/recommendation.cpp b/hws/03_amazon_prime/recommendation.cpp index af8327e..185a06b 100644 --- a/hws/03_amazon_prime/recommendation.cpp +++ b/hws/03_amazon_prime/recommendation.cpp @@ -15,13 +15,12 @@ void RecommendationSystem::recommendMovies(int userId, int numRecommendations, i // calculate similarity scores between the target user (userId) and other users // compute the similarity between the target user and all other users based on their movie ratings using the cosine similarity measure. The resulting similarity scores are stored in the similarityScores array. This information can then be used to recommend movies to the target user based on the preferences of similar users. - double similarityScores[numUsers]; + double* similarityScores = new double[numUsers]; for(int i=0; i