senshi2504's blog

By senshi2504, history, 6 years ago, In English

http://codeforces.com/contest/767/problem/C

I have done some very basic questions of DFS , but I always feel confused and not so sure about , how to systematically formulate my solution in the dfs code . I feel confused , wheather to place certain statements before or after the recurssive call. A similar situation happens for this problem too . I came up with the idea , but feel lost when I have to code it in the dfs solution. I would request this community , to please share your approaches towards handling such DFS codes . Thanks :)

 
 
 
 
  • Vote: I like it
  • +5
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Whenever you have to write recursive codes, never think about how the recursions will go in the middle. Just think at one step what decisions you can make and make those recursive calls. And finally set the base cases. If you think about the recursions trees, then your head will blow.