Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the Fractional Knapsack Problem. 1 . ( 2 5 pts ) Design a greedy algorithm for Fractional Knapsack Problem that finds an optimum solution

Consider the Fractional Knapsack Problem.
1.(25 pts) Design a greedy algorithm for Fractional Knapsack Problem that finds an
optimum solution in O(n log n). Report the pseudocode of your algorithm.
2.(25 pts) Implement your algorithm in Python. Randomly generate the inputs and
report the console outputs. Report your Python code scripts.
Question 2: (50 pts) Consider the Vertex Coloring Problem in which we assign different
colors to the adjacent vertices on a given graph G =(V, E). The objective is to color the
vertices of the graph using minimum number of colors.
Input: A graph G =(V, E), where V is the set of vertices and E is the set of edges of the
graph G.
Output: Color assignments of the vertices using minimum number of colors.
Ex: For the graph G in Figure 1, a vertex is a node in the graph and the set of vertices
is V ={v1, v2,..., v10}. An edge is the line between two vertices and the set of edges is
E ={(v1, v2),(v1, v5),(v1, v6),(v2, v3),(v2, v7),...,(v7, v10)}.
The vertices v1 and v2 are adjacent since there is an edge (v1, v2) between them. On the
other hand, v1 and v7 are not adjacent since there is no edge (v1, v7) in the graph. Notice
that the adjacent vertices v1 and v2 have different colors (red and green, respectively),
whereas non-adjacent vertices v1 and v7 can have the same color (red). We observe that we
can color the vertices of the graph G in Figure 1 with 3 different colors, i.e., red, green, blue.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions

Question

Who responds to your customers complaint letters?

Answered: 1 week ago