Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views6 pages

Search+Algorithms - Search Algorithms

The document discusses various search algorithms, primarily focusing on Depth First Search (DFS) and its characteristics, advantages, and disadvantages, including its memory efficiency and potential for infinite loops. It also covers Depth Limited Search (DLS) as a variant of DFS with a predetermined depth limit, highlighting its memory efficiency but noting its incompleteness and lack of optimality. Additionally, the document briefly compares DFS with Breadth First Search (BFS) in terms of time and space complexity.

Uploaded by

emekabonginkosi4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

Search+Algorithms - Search Algorithms

The document discusses various search algorithms, primarily focusing on Depth First Search (DFS) and its characteristics, advantages, and disadvantages, including its memory efficiency and potential for infinite loops. It also covers Depth Limited Search (DLS) as a variant of DFS with a predetermined depth limit, highlighting its memory efficiency but noting its incompleteness and lack of optimality. Additionally, the document briefly compares DFS with Breadth First Search (BFS) in terms of time and space complexity.

Uploaded by

emekabonginkosi4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

4/16/24, 12:48 PM Search+Algorithms - Search algorithms

Depth First Search Algorithm


• The DFS is a recursive algorithm for traversing a tree or graph data
structure
• The search algorithm is called DFS simply because it start from the root
node and follow each path to its greatest depth node before moving to the
next step path.
• The DFS algorithm uses a stack data structure for its implementation
• The process is similar to BFS algorithm

Advantages
• DFS requires very less memory as it only needs to store a stack of the
node on the path from root node to the current node
• DFS takes less time to reach to the goal node than the BFS algorithm

Disadvantages
• There is the possibility that many states keep re-occurring and there is no
guarantee of finding a solution
• DFS algorithm goes for the deep down searching and sometimes it may
go to the infinite loop
Example

L0 A

L1 B H

L2 C D I J

L3 E F G K

about:blank 1/6
4/16/24, 12:48 PM Search+Algorithms - Search algorithms

Analysis of the DFS in terms of


Completeness: DFS is complete within finite state space, meaning for a given
finite search tree, DFS will come up with a solution if it exists.
Optimality: DFS is not optimal considering the fact that it has the potential to
generate large number of steps or high cost to reach the goal node.
Time complexity: T(n) = 1+n2+n3+…+nm
Where m = max depth of any node
Space complexity
S(c) is the order of O(bm)
Note that the DFS needs to only store single path, so it requires less memory,
hence
S(c) = O(bm)
Where m is the maximum depth of any node and b stands for the level

about:blank 2/6
4/16/24, 12:48 PM Search+Algorithms - Search algorithms

Blurred content of page 3

about:blank 3/6
4/16/24, 12:48 PM Search+Algorithms - Search algorithms

Example

L0 Search path A

H
L1 Search path B

I J
L2 Search path C D

E F G K
L3 Search path

L4 Search path L

Analyses of the BFS in terms of


Time complexity
T(b) = 1+b2+b3+…+bd
=O(bd)
Where “d” = depth of shallowest node and “b” is a node at every state
Space complexity
S(b) = O(bd)
Completeness: Yes BFS is indeed optimal

about:blank 4/6
4/16/24, 12:48 PM Search+Algorithms - Search algorithms

Depth Limited Search Algorithm (DLS)


The DLS is similar to the DFS with a predetermined limit.
DLS can solve the drawback of the infinite path in DFS. In this algorithm, the
node at the depth limit will be treated as if it has no successor nodes further.
The DLS can be terminated with two conditions of failure:
• Standard failure value: This simply indicates that problem does not have
any solution
• Cut off failure value: it defines no solution for the problem within a given
depth limit (i.e. according to the level of depth search, so if no solution is
found in level 0 or level 1, then the search process terminates.

Advantage
• It is memory efficient
Disadvantages
• Incompleteness
• It may not be optimal if the problem has more than one solution

L0 A

H
B
L1

L2 C D I J

L3 E F G K

Let say that the limit of search = level 2

about:blank 5/6
4/16/24, 12:48 PM Search+Algorithms - Search algorithms

Blurred content of page 6

about:blank 6/6

You might also like