How does forum determine new replies for each user? When I visit drupal.org/forum/*, in Replies column I can see how many new posts have been added. Drupal also marks them with a New tag. 

I'm wondering how does drupal determine which replies are new for me? Are they new since my last visit to the page, or my last logout from drupal.org? In case the later is correct, how does drupal know when I loggeout out last time? 

I'm very interested to know what algorithm is behind this nice feature?
Drupal has a history table to record when any user viewed any node.

So it knows when you last viewed the node, and which comments have newer timestamps. So it marks those comments with newer timestamps as new or updated.

UPDATE: There is also a constant NODE_NEW_LIMIT set in the node.module file which defaults to 30 days ago. That means nodes changed before 30 days are always marked as read.