Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Result: List
Result: List First we copy all the heads  of status updates to our list
Result: List
Result: List Now, let's sort the list by date order – last first
Result: List
Result: List Let's pop the first item in line, and get the next one
Result: List 1 2
Result: List Time to sort the list again
Result: List
Result: List Pop the first, get the next
Result: List 1 2
Result: List Sort
Result: List
Result: List Pop, get next
Result: List 2 1
Result: List Sort
Result: List
Result: List Pop, get next
Result: List 1 2
Result: List Sort
Result: List List
Result: List List Pop, get next
Result: List List 2 1
Result: List List Sort
Result: List List
Result: List List Pop, get next
Result: List List 1 2
Result: List List Sort
Result: List List (already sorted)
Result: List List Pop the first one in line Since it's the last for Anna, we remove that iterator  from our list
Result: List List
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'...
Result: List List
Result: List List Last one. Nothing  added, so no sort. Pop and get.
Result: List List
Upcoming SlideShare
Loading in …5
×

Pattern: Activity stream

5,883 views

Published on

  • 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.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

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

×