Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Artificial Intelligence for Search

You're reading from   Hands-On Artificial Intelligence for Search Building intelligent applications and perform enterprise searches

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781789611151
Length 124 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Devangini Patel Devangini Patel
Author Profile Icon Devangini Patel
Devangini Patel
Arrow right icon
View More author details
Toc

BFS versus DFS

In this section, we'll look at the differences between the DFS and BFS algorithms. We will compare these differences in terms of various factors.

Order of traversal

In DFS, preference is given to child nodes, which means that after node a and node b are explored, and after node b and node c are explored, we hit a dead end and we backtrack to the previous level. This means that we go back to node b, and then to its next child, which is node c.

In BFS, the nodes are covered level by level, and preference is given to siblings. This means that after node a, nodes b and e are explored, and after that, nodes c, d, and f are explored, as indicated by the following diagram:

Figure 16
...
You have been reading a chapter from
Hands-On Artificial Intelligence for Search
Published in: Aug 2018
Publisher: Packt
ISBN-13: 9781789611151
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image