Search Algorithms

advertisement
Search Algorithms
There are many different search algorithms with can be used to locate data in a program.
These include "Linear Search", "Binary Search" , "Tree Search" and "Genetic Algorithms"
each of these have their own advantage and should be used in different scenarios.( C.Mano
,2014)
Linear Search
This is the simplest form of search algorithm and is generally best used for searching small
lists, mainly due to being simple and requiring very little code to implement .The algorithm is
the process of starting from the beginning of a list, checking each item in tern until either the
desired item/data is located, or the end of the list has been reached. However due to the way
the algorithm functions, large lists can take a very long time to locate data compared to other
forms of algorithms. A linear search algorithm is usually done by creating a loop in the
program which goes though and checks each item. An advantage of the linear search is that
data in the list doesn't have to be pre-sorted before the data can be located, this can speed up
the process slightly. However long lists of data will still take a very long time to search as
"The duration of the search grows linearly with the number of items in the collection."
(algorithms.openmymind ,2011)
Binary Search
Binary Search works by sorting a list of data in order and then splitting the list in half
determining if the required value is higher or lower than the half way point. This smaller list
is then split in half and checked again, the process is repeated until the requested value is
located. This method can be much faster than linear search when dealing with long lists as the
algorithm doesn't have to cycle though every value in tern and only needs to check midpoints.
As stated prior the data has to be sorted before it can be searched which can take time.
Therefore Binary Search is not the most efficient at searching small lists as it may take the
same amount of time or longer than Linear search while requiring more coding to implement.
(algorithms.openmymind ,2011)
Tree Search
There are two other forms of Binary Search which are used when the data in stored in trees
and are used to find a path connecting data nodes in a graph (Sandy Taramonli & YL Hedley,
2015). These are the following:
Depth First Search
A depth First algorithm works by going down each branch in tern until the end of the node
branch is reached and then goes down the next branch until the required data is found. The
advantages of using this algorithm is that it requires less memory than the Breadth First
Search . However one problem with this type of search is that it may waste a great deal of
time going down the wrong trees and may take a while to find the data. Therefore this type of
search algorithm is probably best suited to narrow and tall data trees which the algorithm can
search more effectively.
(Unknown,2009)
Breadth First Search
A Breadth First Search algorithm works by starting at the initial node and moving down and
across the tree until the data is found or the end of the tree is reached. The advantages of the
Breadth First Search is that unlike the Depth First Search it wont get stuck going down a very
long branch to find the required data. The disadvantage of this algorithm is that the computer
has to store each level of the tree the algorithm visits, this means that the algorithm isn't very
effective at searching narrow tall trees. The algorithm is most effective at search data trees
which are wide and short, which is the opposite of the Depth First Search.
(Unknown,2009)
Genetic Algorithms
These are used in artificial intelligence has works by searching the data for the fastest solution
to the problem.
( C.Mano ,2014)
References
C.Mano. (2014). Types of Search Algorithms. Available:
http://www.ehow.com/info_8404823_types-search-algorithms.html. Last accessed 30/1/2015.
Unknown. (2011). Binary Search. Available:
http://algorithms.openmymind.net/search/binarysearch.html. Last accessed 21/1/2015.
Unknown. (2011). Linear Search. Available:
http://algorithms.openmymind.net/search/linear.html. Last accessed 21/1/2015.
Unknown. (2009). DEPTH FIRST SEARCH. Available:
http://intelligence.worldofcomputing.net/ai-search/depth-first-search.html#.VMzzr2isV8F.
Last accessed 25/1/2015.
Unknown. (2009). BREADTH FIRST SEARCH. Available:
http://intelligence.worldofcomputing.net/ai-search/breadth-first-search.html#.VMzz_GisV8F.
Last accessed 25/1/2015.
Sandy Taramonli & YL Hedley. (2015). Search Algorithms. Available:
https://cumoodle.coventry.ac.uk/pluginfile.php/663997/mod_resource/content/2/Python%20B
asics%20Lab%206%20-%20Search%20Algorithms%20v2.pdf. Last accessed 25/1/2015.
cprogramming. (2014). Linear Search, Binary Search and other Searching
Techniques. Available:
http://www.cprogramming.com/discussionarticles/sorting_and_searching.html. Last accessed
25/1/2015.
Unknown. (2014). Searching. Available:
http://www.dcs.warwick.ac.uk/~zabin/seqsearch.pdf. Last accessed 22/1/2015.
Download