






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A detailed explanation of Depth First Search (DFS) algorithm, a blind searching technique used in Artificial Intelligence. the theory behind search problems, the concept of search representation, and the steps involved in implementing DFS using a stack. It includes a lab manual from The University of Lahore, Islamabad Campus, School of Information Technology (SIT), CS13217, and is written by Hafiz Muhammad Umer. The document aims to help students understand the searching process in DFS and program the technique.
Typology: Lab Reports
1 / 10
This page cannot be seen from the preview
Don't miss anything!







Objective: To implement and understand blind searching techniques such as Depth First Search (DFS) Learning Outcomes: The Students will be able to: a) Understand the searching in DFS b) Program DFS Technique Theory: If we want to go from Point A to Point B, you are employing some kind of search. For a direction finder, going from Point A to Point B literally means finding a path between where you are now and your intended destination. For a chess game, Point A to Point B might be two points between its current position and its position 5 moves from now. For a genome sequencer, Points A and B could be a link between two DNA sequences. As you can tell, going from Point A to Point B is different for every situation. If there is a vast amount of interconnected data, and you are trying to find a relation between few such pieces of data, you would use search. Searching falls under Artificial Intelligence (AI). A major goal of AI is to give computers the ability to think, or in other words, mimic human behavior. The problem is, unfortunately, computers don't function in the same way our minds do. They require a series of well-reasoned out steps before finding a solution. Your goal, then, is to take a complicated task and convert it into simpler steps that your computer can handle. That conversion from something complex to something simple is what this tutorial is primarily
Depth First Search Depth first search works by taking a node, checking its neighbors, expanding the first node it finds among the neighbors, checking if that expanded node is our destination, and if not, continue exploring more nodes. Step 0 Let’s start with our root/goal node: I will be using two lists to keep track of what we are doing - an Open list and a Closed List. An Open list keeps track of what you need to do, and the Closed List keeps track of what you have already done. Right now, we only have our starting point, node A. We haven't done anything to it yet, so let's add it to our Open list. Open List: A Closed List:
this step though. You now have two new nodes B and C that need exploring. Add those two nodes to our Open list. Our current Open and Closed Lists contain the following data: Open List: B, C Closed List: A Step 2 Our Open list contains two items. For depth first search and breadth first search, you always explore the first item from our Open list. The first item in our Open list is the B node. B is not our destination, so let's explore its neighbors: Because I have now expanded B, I am going to remove it from the Open list and add it to the Closed List. Our new nodes are D and E, and we add these nodes to the beginning of our Open list: Open List: D, E, C Closed List: A, B Step 3 We should start to see a pattern forming. Because D is at the beginning of our Open List, we expand it. D isn't our destination, and it does not contain any neighbors. All you do in this step is remove D from our Open List and add it to our Closed List: Open List: E, C Closed List: A, B, D
The final path taken by our depth first search method is what the final value of our Closed List is: A, B, E, F. Pseudocode Now that we have a good idea on how to solve these various search problems, we need to translate them so that a computer can solve it. let's solve it generally using pseudocode, or if you prefer a better name, an informal algorithm. Performing via stack Tasks
int V; list
Output Vertices are 8 because in graph total nodes are 8 Conclusion
(Concerned Teacher/Lab Engineer)