You are on page 1of 2

DCIT 313 ASSIGNMENT

1. Breadth First Search (BFS): BFS is a search algorithm that explores all the
vertices at a given level before moving on to the next level. It visits all the
vertices at distance 1 from the starting vertex, then all the vertices at
distance 2, and so on, until the goal vertex is found, or all vertices have
been visited. BFS is implemented using a queue, where vertices are added
to the queue as they are discovered, and they are removed from the queue
and processed in the order they were added. An example of BFS is finding
the shortest path between two cities on a map, where the algorithm visits
all the cities at a certain distance from the starting city before moving on to
cities that are further away.
2. Depth First Search (DFS): DFS is a search algorithm that explores as deep as
possible in a branch before backtracking and exploring another branch. It
visits a vertex, then visits one of its unvisited children, and repeats the
process until it reaches a dead end, and then backtracks to the previous
vertex and visits another unvisited child. DFS is implemented using a stack,
where vertices are added to the stack as they are discovered, and they are
removed from the stack and processed in the reverse order they were
added. An example of DFS is searching for a specific file on a computer's file
system, where the algorithm visits all the subdirectories and files in a
directory before moving on to the next directory.
3. Iterative Deepening: Iterative deepening is a search algorithm that
combines the benefits of BFS and DFS by repeatedly applying DFS with
increasing depth limits. It starts with a depth limit of 1, which is equivalent
to a DFS with a depth of 1, then increases the depth limit to 2, 3, and so on,
until the goal vertex is found, or the depth limit is reached. Iterative
deepening ensures that the goal vertex is found in a reasonable amount of
time, and it is more efficient than BFS because it does not have to visit all
the vertices at a given level before moving on to the next level. An example
of iterative deepening is searching for the shortest path in a maze, where
the algorithm starts by exploring the closest cells and gradually expands its
search to cells that are further away.
4. A*: A* is a search algorithm that combines the benefits of BFS and DFS by
using an estimated cost function to prioritize which vertices to visit next.
The estimated cost function, also known as the heuristic, is a measure of
the estimated cost of reaching the goal vertex from a given vertex. A* uses
the heuristic to prioritize vertices that are estimated to be closer to the goal
vertex, and it also keeps track of the actual cost of reaching a vertex from
the starting vertex. A* is implemented using a priority queue, where
vertices are added to the queue with a priority that is based on the
estimated cost of reaching the goal vertex. An example of A* is finding the
shortest path between two cities on a map, where the algorithm uses the
estimated driving time between cities to prioritize which cities to visit next.

You might also like