0% found this document useful (0 votes)
11 views1 page

Data Structure and Algorithm Task

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Data Structure and Algorithm Task

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Data Structures & Algorithms

Assignment # 4

(CLO-2, CLO-4 Marks: 10 + 10)

Create a class graph that represents an undirected graph using an adjacency list.

The graph should support the following operations:

o add_edge(u, v): Adds an edge between vertex u and vertex v.


o remove_edge(u, v): Removes the edge between vertex u and vertex v.
o get_neighbors(u): Returns the list of neighbors of vertex u.

o display_graph(): Prints the entire graph.


o Breadth-First Search (BFS): Traverses the graph level by level, starting from a
given node.
o Depth-First Search (DFS): Traverses the graph by exploring as far as possible
along each branch before backtracking.

Time Complexity Analysis:

 For both BFS and DFS operations, measure the time it takes to execute the operation on
graphs of different sizes (e.g., 100, 500, 1000 vertices):

You might also like