Upcoming SlideShare
Loading in …5
×

Pattern: Activity stream

5,149
-1

Published on

1 Comment
2 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• This algorithm becomes incredibly slow when dealing with relatively large numbers of relationships. Imagine if Andreas had a measly 300 friends (which is actually quite a small number, given Twitter followers range in the thousands for everyday users and in the millions for celebs). You would have to perform an O(k * n log n) where k is the number of items to retrieve and n is the number of people Andreas is friends with. This is simply not scalable with even a modestly sized social network.

Are you sure you want to  Yes  No
Your message goes here
No Downloads
Views
Total Views
5,149
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
36
Comments
1
Likes
2
Embeds 0
No embeds

No notes for slide

Pattern: Activity stream

1. 1. Result: List
2. 2. Result: List First we copy all the heads of status updates to our list
3. 3. Result: List
4. 4. Result: List Now, let's sort the list by date order – last first
5. 5. Result: List
6. 6. Result: List Let's pop the first item in line, and get the next one
7. 7. Result: List 1 2
8. 8. Result: List Time to sort the list again
9. 9. Result: List
10. 10. Result: List Pop the first, get the next
11. 11. Result: List 1 2
12. 12. Result: List Sort
13. 13. Result: List
14. 14. Result: List Pop, get next
15. 15. Result: List 2 1
16. 16. Result: List Sort
17. 17. Result: List
18. 18. Result: List Pop, get next
19. 19. Result: List 1 2
20. 20. Result: List Sort
21. 21. Result: List List
22. 22. Result: List List Pop, get next
23. 23. Result: List List 2 1
24. 24. Result: List List Sort
25. 25. Result: List List
26. 26. Result: List List Pop, get next
27. 27. Result: List List 1 2
28. 28. Result: List List Sort
29. 29. Result: List List (already sorted)
30. 30. Result: List List Pop the first one in line Since it's the last for Anna, we remove that iterator from our list
31. 31. Result: List List
32. 32. Result: List List Since nothing new was added, let's just pop the first one. It's also the last in that iterator, so let's remove it from the list.
33. 33. Result: List List
34. 34. Result: List List Last one. Nothing added, so no sort. Pop and get.
35. 35. Result: List List