It is implemented in recursion with LIFO stack data structure. It creates the same set of nodes as Breadth-First method, only in the different order.
As the nodes on the single path are stored in each iteration from root to leaf node, the space requirement to store nodes is linear. With branching factor b and depth as m, the storage space is bm.
Disadvantage: This algorithm may not terminate and go on infinitely on one path. The solution to this issue is to choose a cut-off depth. If the ideal cut-off is d, and if chosen cutoff is lesser than d, then this algorithm may fail. If chosen cut-off is more than d, then execution time increases.
Its complexity depends on the number of paths. It cannot check duplicate nodes.
Latest posts by FreelancingGig (see all)
- Freelancers, Crypto Payments, and Taxes: An Ultimate Guide - March 17, 2023
- Freelance Environmental Consultant for Corporations: 4 FAQs About the Role Answered - February 11, 2023
- The Benefits of Taking Your Business Online With Print on Demand - January 20, 2023