Memory Referrence Issue In Recursive Algorithm - C#