I've only been coding for a few months now and I don't have a CS background. This is my first post on LC. From what I gather, some problems can be solved only using BFS and not DFS, some problems the other way around, and some others have both approaches. Is that correct?
If the problem can only be solved by one of the approaches, how do I recognize which approach is appropriate?
If the problem can be solved by either approach, how do I decide which approach is more efficient for that problem?
I have a similar confusion when it comes to iterative vs recursive solutions. Can an iterative solution always be converted to a recursive solution and vice versa? At least in the situations where this can be done, how do I decide which would be more efficient for the given problem?
I understand that my questions may be vague and difficult to answer but I'm merely looking for guidelines and tips or hacks that you've learnt through experience that could help me figure it out for each question. I don't expect there to be hard and fast rules or a clear answer to which approach is better.
Thanks in advance for your time. I've learnt so much from this community already.