Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
How do both solutions use BFS if they both make recursive calls? In almost all c...

J

Dec 4, 2022

How do both solutions use BFS if they both make recursive calls? In almost all cases, doesn't recursion with some kind of linear data structure input in general imply DFS and not BFS?

3

0

Comments
Comments
Design Gurus
Design Gurus3 years ago

DFS and recursion are unrelated. Mostly we see recursive solutions for DFS, but as we know any recursive solution can be converted to an iterative solution using a stack; hence, you can write iterative DFS.

DFS and BFS, refer to search pattern, that is either we are se...

On this page