Best answer
It depends on what situation, really. In usual situation, to show respect you can say: “Sensei, doumo arigatou gozaimasu/gozaimashita.” And don”t forget to bow after that! Action speaks louder than words.
If you are leaving for good, or your Sensei is and presumably you will not see each other easily for a very long time, you can add “Taihen osewa ni narimashita” after saying “doumo arigatou gozaimashita. And again don”t forget to bow after that.
Answer
__先生ありがとうございました。
__sensei arigatou gozai mashita.
Thank you __sensei.
__先生ありがとうございます。
__sensei arigatou gozai masu.
Thank you __sensei.
__先生、どうもありがとうございました。
__sensei, doumo arigatou gozai mashita.
Thank you very much, __sensei.
__先生感謝しています。
__sensei kansha shiteimasu.
I am thankful for you, __sensei.
__先生のおかげで、__ができました。
__sensei no okaged, __ga dekimashita
- because __sensei taught me / helped me, I could do __ very well.
- because__sensei taught me / helped me, I exceeded in doing __.
__先生にありがたいです。
sensei ni arigataidesu
I am thankful for __sensei.