The Partition into paths of lenght 2 problem is as follows I

The Partition into paths of lenght 2 problem is as follows

Instance: A graph, G = (V,E) with |V| = 3q for a positive integer q

Question: is there a partition of C inro q disjoint subsets V1,V2..Vq of 3 vertices such that for each Vi = {Vi[1], Vi[2], Vi[3] } at least two of the the three edges {Vi[1], Vi[2], }, {Vi[1],Vi[3]} and {Vi[2],Vi[3]} belong to E.

Prove the partition into paths of lenght 2 problem is NP complete

Solution

struct node* display(struct node* start)
{
struct node *new_node;
printf(\"\ The Linked List : \");
new_node=start;
while(new_node!=NULL){
printf(\"\ %d\",new_node->pid);
printf(\"\\t %s\", new_node->fname);
printf(\"\\t %s\",new_node->sname);
new_node=new_node->next;
}
return start;
}

struct node* sort(struct node* start){
struct node *ptr1,*ptr2;
char temp[10];
int i;
while(ptr1->next!=NULL){
ptr2=ptr1->next;
while(ptr2!=NULL){
if(ptr1->sname[0]>ptr2->sname[0]){
for (i=0;i<2;i++)
temp[i]=ptr1->sname[i];
for (i=0;i<2;i++)
ptr1->sname[i]=ptr2->sname[i];
for (i=0;i<2;i++)
ptr2->sname[i]=temp[i];
}
ptr2=ptr2->next;
}
ptr1=ptr1->next;
}
return start;
}


//----------------------------------------------------
int main()
{
start=create(start);
start=sort(start);
start=display(start);
getch();
}

The Partition into paths of lenght 2 problem is as follows Instance: A graph, G = (V,E) with |V| = 3q for a positive integer q Question: is there a partition of

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site