What is a Search Algorithm.docx
What is a Search Algorithm.docx
Search algorithms play a crucial role in computer science and various applications
by efficiently locating specific items within a collection of data. Here are some key
roles and applications of search algorithms:
1. Information Retrieval: Search engines like Google and Bing use sophisticated
search algorithms to retrieve relevant information from vast amounts of data on the
web1.
2. Database Systems: Search algorithms are fundamental in database systems for
quickly querying and retrieving specific data records based on user queries1.
5. SEO (Search Engine Optimization): In SEO, search algorithms determine how
search engines rank and display relevant information against user queries, improving
website visibility on search engine result pages (SERPs)2.
Types of search algorithm:
Uninformed Searching
Informed Searching
Real life example: Navigating a maze Real life example: GPS navigation
without any clues about the exit systems using real-time traffic data to
location. find the fastest route.
Output: The BFS traversal of the graph or the path to the goal vertex g if specified.
Algorithm:
1. Initialize:
o Create a queue Q.
o Enqueue the starting vertex s into Q.
o Mark s as visited.
2. While Q is not empty:
Steps:
/ \
B C
/ \ \
D E F
Example:
● Start at node A.
● Enqueue A. Queue: [A]
● Dequeue A, enqueue B and C. Queue: [B, C]
● Dequeue B, enqueue D and E. Queue: [C, D, E]
● Dequeue C, enqueue F. Queue: [D, E, F]
● Dequeue D. Queue: [E, F]
● Dequeue E (goal node found).
Output: The DFS traversal of the graph or the path to the goal vertex g if specified.
Algorithm:
1. Initialize:
o Create an empty stack S.
o Push the starting vertex s onto S.
o Mark s as visited.
2. While S is not empty:
Steps:
● Start at node A.
● Push A. Stack: [A]
● Pop A, push B and C. Stack: [C, B]
● Pop B, push D and E. Stack: [C, E, D]
● Pop D. Stack: [C, E]
● Continue this process until the goal node is found.
Example:
A
/ \
B C
/ \ \
D E F
● Start at node A.
● Push A. Stack: [A]
● Pop A, push B and C. Stack: [C, B]
● Pop B, push D and E. Stack: [C, E, D]
● Pop D. Stack: [C, E]
● Pop E (goal node found).