How should I thank my advisors at the end of my program? I've finished all of the requirements for my master's degree and am going to graduate this summer. As I finish up, I want to thank my advisors for investing in me so much over the last few years.

What are some appropriate ways for me to thank my advisors? (One of my advisors moved out-of-state after I started working with her, so unfortunately, I won't be able to thank her in person.)
Write a nice thank you letter
Keep in touch; send an email every couple of years to let them know about your recent successes
Pay it forward by investing your own time and energy into mentoring others, as time and opportunity permits


My "gratitude role model" is a high school summer research student I had a few years ago. 


First, she gave me a card with a nice message at the end of the program. 
A year later, she emailed me to let me know that her time in my lab had really meant a lot to her, that she was still pursuing her interest in computer science, and that she was participating in another CS program that summer. 
From her next email, a year later, I found out that she had accepted an offer of admission (for undergraduate studies) from a top-20 computer science department. 
A couple of months ago, I got an email from my school's K-12 outreach program (which had organized her summer in my lab), informing me that this student had reached out to them to ask if she could volunteer in their programs this summer, while she's back in town.


Working with students can be a thankless task; but the students like the one I described above really keep me going, and make me feel like it is time well spent. I cannot imagine a better way to be thanked.