Docsity

CS 303 Assignment 4: Graph Theory and Spanning Trees, Assignments of Computer Science

Toggle sidebar
bg1
CS 303 - Assignment 4
Written Homework:
1. Write the adjacency matrix and adjacency list representation of the following
undirected graph:
2. How can Linked List data structure be used for adjacency list representation of
graph?
3. Which of the following finds the lowest-cost way to connect all of the vertices?
a) Minimum Spanning Tree
b) Shortest Path Tree
4. Which of the following finds the lowest-cost path between two given vertices?
a) Minimum Spanning Tree
b) Shortest Path Tree
pf3

Partial preview of the text

Download CS 303 Assignment 4: Graph Theory and Spanning Trees and more Assignments Computer Science in PDF only on Docsity!

CS 303 - Assignment 4

Written Homework:

  1. Write the adjacency matrix and adjacency list representation of the following undirected graph:
  2. How can Linked List data structure be used for adjacency list representation of graph?
  3. Which of the following finds the lowest-cost way to connect all of the vertices? a) Minimum Spanning Tree b) Shortest Path Tree
  4. Which of the following finds the lowest-cost path between two given vertices? a) Minimum Spanning Tree b) Shortest Path Tree

Programming Problem:

  1. Implement the Adjacency Matrix representation of Graph. Input will be provided as a multidimensional array. eg: input = {{1,2}, {2,4}, {3,2}, {3,4}, {4,5}, {0,1}};
  2. The required task is to read each of such pairs and store in adjacency matrix. The nodes are represented by integers starting from 0 and increasing sequentially. So these numbers can be used to identify the nodes, without need of labels.
  3. Add functionality to perform Breadth First Search and Depth First Search in the graph, given start node and a node to be searched. After the node is found also print the path from start node to the search node. Given a node as a starting point, find a spanning tree that spans all the vertices of the graph. While visiting the nodes, you may need to maintain the list of nodes that have already been visited so that infinite loop will not occur. Spanning tree: Given a connected, undirected graph, a spanning tree of that graph is a sub-graph which is a tree (non-cyclic) and connects all the vertices. Hence, a graph may have many different spanning trees. The following Figures illustrate two different spanning trees. Bonus Problem: Write a program for Adjacency List representation of Graph with all the functionality above. You may use the suitable data structure you created in past lab or provided by java for the underlying storage.