algorithm - Which of my friends have the same 'like'? -
I have a web app where every user can be a user, users can see different pages of their site such as: < / P>
pizza.html hamburger.html etc
If I am a user, seeing the page 'pizza.html', I want to know that this page 'liked' from my friends is also this page. Assuming this, I want to show this when I load the pizza.html, I can really do it on demand:
I am a user; Like current = "pizza.html"; & Lt; Users & gt; FriendsWhoAlsoLikePageImLookingAt; (User friend: me.getFriends ()) {for (eg: friend.getLikes ()) {if (like == present) {friendsWhoAlsoLikePageImLookingAt.add (friend); }}} // Now friends who are all my friends in other types of page im listening, which I see.
This will work, but will be really bad, as friends # and their choice increases. Is there an algorithm that I can see to solve it?
Another approach will be precomputed all the choices for each user (I think it will not be good) For example, each user gets his TCT file for his interest such as: / P>
userA_pizza.txt userB_pizza.txt userA_hamburger.txt userB_hamburger.txt ...
Believing that I am a friend with UserB, and UserB is a new Like 'pizza.html' - then I update the userA_pizza.txt file to see it like this. Ll:
// userA_pizza.txt userB // latest friends also like this interest UserX // Previous friends like userY // previous friends likes
Now whenever I look at the userA pizza page, I can open 'userA_pizza.txt' and dump all the friends' names without any computation. Now every time the user likes a page I have to update N Text files, where N is the number of my friends. In addition, each user will need a text file for possible interest (and there can be thousands of interests) If a user has 100k friends and they have 1000 interests, then this can be very expensive!
Yes, then any thoughts or ideas will be great
thanks
User table (id, name, etc.) You can ask the table of pages you liked with UserId to see a list of all the choices for a user. You can also ask against the PageID that who liked this page. The intersection of those two questions is the result you are looking for.
Comments
Post a Comment