Search Algorithms

advertisement
Different types of Search Algorithms
For our project we will need to be able to use some type of searching method to find
objects. We will be using a search algorithm for the Robot(S) to find different
Treasures on the chosen map. I am going to talk about the different types of search
algorithms available for this type of project and explain the difference.
Linear search
Linear search can be described as one of the simplest search algorithms. It works by
searching through a list of numbers or objects that doesn’t have to be in order. The
search will commence by comparing the selected number or object to be found by
each item in the list. It will keep doing this throughout the list until it has found its
target, then it is done and stops.
Although it is the simplest one it is also not efficient, because if the list isn’t in order
the search will need to continue until all items are check and the target is found. If
the list were to be placed in order it would be efficient but can be time consuming
(Reid, 2000) .
Binary Depth-first Search Algorithm (DFS)
This type of algorithm is used to find the connecting nodes in a graph tree, which can
be represented by lists or dictionaries. The search first starts at the root and then
follows one of the branches as far as possible until the node you are searching for is
found or until you reach the end of the branch (a node with no child). If the search
hits the child node, it will still carry on its search continuing onto the other child nodes
not visited (Sahgal, 2013).
Figure 1: Example of DFS, showing which order each node is accessed.
Binary Breadth-first Search Algorithm (BFS)
In Binary first search you start at the root just like DFS and then go along one of the
branches. The search will continue on this branch scanning each node until the final
node. It will not search the child nodes of that branch until it has reached the end of
that branch. Once done, it will move onto the next level or the branch and continue
its search as before.
Compared to DFS, BFS can be considered slow but if the search was to find a node
at the top of the tree it would be a lot quicker (Sahgal, 2013).
Figure 2: Example of BFS, showing which order each node is accessed.
Bibliography
Reid, K., 2000. Linear and Binary Search Algorithms. [Online]
Available at: http://www.cs.toronto.edu/~reid/search/algs.html
[Accessed 21 January 2015].
Sahgal, V., 2013. What’s the difference between DFS and BFS?. [Online]
Available at: http://www.programmerinterview.com/index.php/data-structures/dfs-vsbfs/
[Accessed 21 January 2015].
Download