Вы находитесь на странице: 1из 2

Assignment – 1 (CLO-3)

Problem description:

For this assignment, you will write 2 Python programs to perform Breadth-First Search and Depth-First
Search. Your program should be able to print the sequence of all the nodes visited according to the
Search algorithm selected.

Breadth-First search (BFS) is an algorithm used for traversing graph data structures. BFS starts with an
initial node (Start Node), then it checks the neighbors of the Start Node, then the neighbors of the
neighbors, and so on. Two vertices are ‘neighbors’ if they are connected with an edge.

Depth-First search explores possible vertices (from a supplied root) down each branch before
backtracking.

The algorithms for both these approaches are included in the lecture slides and we have also seen
worked examples of how they work. Your task is to use the algorithm from the slides and implement it
in Python. You are supplied with a pyGraph.py file which is a Python file that contains the code for the
Graph class. This code will help you create the graph in Python. The remaining code you have to write
according to the BFS and DFS algorithms in slides.

Input:

• Your program does not need any input from the user. You can specify the starting node and the
goal node within your code.
• You will get BONUS marks if you implement the code that allows the user to input Nodes and
Edges from the terminal.

Output:

The output should show the PATH (sequence of nodes) and the TIME your algorithm took to reach the
GOAL node from the START node.

Deliverable:

• You should upload a zip file containing the assignment folder. The folder should contain the
following:
1. 2 separate Python files. BFS.py and DFS.py
2. You can also use Jupyter Notebooks in which case the files would be BFS.ipynb and
DFS.ipynb.
3. Screenshots of your program output.
Note:

• This is an individual assignment (no groups).


• A certain number of submissions selected RANDOMLY, WILL be asked to give a VIVA for their
code.
• Deadline: 11:59 PM, 17th March, 2019. No late submissions allowed/accepted.
• Make sure all files have your Names and Enrolment numbers.

Recommendation:

• It is recommended that you download and install Anaconda Navigator from Anaconda.org.
Anaconda Navigator provides a complete suite of tools including Python interpreters and IDEs
and Jupyter Notebooks. It makes it easier to manage Python code.

WARNING:

• PLEASE DO NOT COPY/PASTE THE CODE FROM THE INTERNET. YOU HAVE THE ALGORITHMS
DEFINED THE LECTURE SLIDES. YOU NEED TO USE THAT AND WRITE YOUR OWN CODE. IF
YOUR CODE IF FOUND TO BE COPIED FROM SOMEWHERE, YOU WILL GET A 0 IN THIS
ASSIGNMENT AS WELL AS THE NEXT ASSIGNMENT.
• YOUR EFFORTS WILL BE REFLECTED FROM THE QUALITY OF THE CODE PRODUCED.

Вам также может понравиться