

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
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Assignment; Professor: Sitaraman; Class: Intro To Algorithms; Subject: Computer Science; University: University of Massachusetts - Amherst; Term: Unknown 1989;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!
Note: We did this problem in the discussion hour. If you did not attend this class, please make sure that you talk to your friends or come and meet me.
Description:
In this programming assignment, you must write an efficient program to determine whether or not an (undirected) graph G = (V, E) is 2-colorable. Your algorithm should run in O(|V | + |E|) steps. Please a language such as C, C++, or Java for this assignment.
A graph is said to be 2-colorable if and only if it is possible to assign one of two colors (say red or blue) to each of the nodes of the graph such that no two nodes which are connected by an edge are assigned the same color.
The input file to your program is in the following format. The first line of the file contains the number of nodes (|V |). The nodes are numbered 1 through |V |. Each subsequent line contains a pair of nodes such that each such pair defines an edge. You are provided with three different input files in directory /courses/cs300/cs311/cs311/311 PROG1 INPUT on the EDLAB machines. The names of the input files are smallgraph, largegraph1, and largegraph2. You must run your program on all three input files.
Checklist of what you must submit:
Helpful Hints: You want to consider using standard search techniques like BFS and DFS and modifying them.
Administrivia: You must use the EDLAB for doing these assignments. All of you have accounts on the EDLAB machines (if you do not, contact the TA or me). After you login please type cd cs311, so that you do all your work for this course in the cs311 directory.