Modify the original inventory.c program that we wrote in class by making inventory and num parts local to the main function.
Homework Help Tutorials Solutions
Wednesday, April 20, 2022
Modify the original inventory.c program that we wrote in class by making inventory and num parts local to the main function.
In a system with 100 processors (multiprocessor), each processor reaches a maximum operating speed of 2Gflops. If 2% of the code we want to run in such a system can be serial and 98% parallel, what will be the performance of the system in terms of Gflops?
In a system with 100 processors (multiprocessor), each processor reaches a maximum operating speed of 2Gflops. If 2% of the code we want to run in such a system can be serial and 98% parallel, what will be the performance of the system in terms of Gflops?
Q2. As new links are created and old ones are removed among an existing set of Web pages, thepages move between different parts of the bow-tie structure. (05)(a) Name an edge you could add or delete from the graph in Figure 3 so as to increase the size ofthe largest strongly connected component.(b) Name an edge you could add or delete from the graph in Figure 3 so as to increase the size ofthe set IN.(c) Name an edge you could add or delete from the graph in Figure 3 so as to increase the size ofthe set OUT.
Q2. As new links are created and old ones are removed among an existing set of Web pages, thepages move between different parts of the bow-tie structure. (05)(a) Name an edge you could add or delete from the graph in Figure 3 so as to increase the size ofthe largest strongly connected component.(b) Name an edge you could add or delete from the graph in Figure 3 so as to increase the size ofthe set IN.(c) Name an edge you could add or delete from the graph in Figure 3 so as to increase the size ofthe set OUT.
strongly connection component : It is the subgraph of the given graph where each node can be reachable from every other vertex in the selected subgraph
In set : set of all nodes which have an incoming edge incident upon the node
out group: set of all nodes which have an outgoing edge from the node
first question : you can never increase the size of the strongly connected component with deleting an edge you must always add an edge
the largest strongly connected component in the given graph is the 9,14,15 and we can increase the size by adding another edge 9->13
second question: when we add the edge 11->6 we will increase the inset because there is no in edge on node 6 so it is not present in the in set now once we add the 11->6 edge it will be added to inset and the size will be increased
third question :
when we add the edge 2->7 we will increase the out group because there is no out edge from node 2 so it is not present in the out group now once we add the 2->7 edge it will be added to out group and the size will be increased
Using C++,Given a directed line from point p0(x0, y0) to p1(x1, y1), you can use the following condition to decide whether a point, p2(x2, y2) is on the left of the on the right, or on the same line. > 0 ; p2 is on the left side of the line ( x1 - x0 ) * ( y2 - y0 ) - ( x2- x0 ) * ( y1 - y0 ) = 0 ; p2 is on the same line (a) p2 is on the left of the line (b) p2 is on the right of the line (c) p2 is on the same line Write a program that prompts the user to enter the x-y coordinates for the three points p0, p1, and p2 and displays whether p2 is on the left of the line from p0 to p1, on the right, or on the same line.
Using C++,Given a directed line from point p0(x0, y0) to p1(x1, y1), you can use the following condition to decide whether a point, p2(x2, y2) is on the left of the on the right, or on the same line.
> 0 ; p2 is on the left side of the line
( x1 - x0 ) * ( y2 - y0 ) - ( x2- x0 ) * ( y1 - y0 ) = 0 ; p2 is on the same line
(a) p2 is on the left of the line
(b) p2 is on the right of the line
(c) p2 is on the same line
Write a program that prompts the user to enter the x-y coordinates for the three points p0, p1, and p2 and displays whether p2 is on the left of the line from p0 to p1, on the right, or on the same line.
import java.util.Scanner; public class Lab01 {
public static void specifyposition(int x0,int y0,int x1,int y1,int x2,int y2){
double val = (x1 - x0)*(y2 - y0) - (x2 - x0)*(y1 - y0);
if(val>0) System.out.println("p2 is on the left side of the line"); else if (val==0) System.out.println("p2 is on the same line"); else System.out.println("p2 is on the right side of the line"); } public static void main(String[] args) {
Scanner sc = new Scanner(System.in); System.out.println("Enter coordinate for three points: "); System.out.println("Enter coordinate for P0: "); int x1 = sc.nextInt(); int y1 = sc.nextInt(); System.out.println("Enter coordinate for P1: "); int x2 = sc.nextInt(); int y2 = sc.nextInt(); System.out.println("Enter coordinate for P2: "); int x3 = sc.nextInt(); int y3 = sc.nextInt();
specifyposition(x1,y1,x2,y2,x3,y3); } } |
OUTPUT:
Enter coordinate for three points: Enter coordinate for P0: 2 3 Enter coordinate for P1: 4 5 Enter coordinate for P2: 2 3 P2 is on the same line |
You need to compare a student's behavior when locating admission requirements of a university. (i) A complete hierarchical task analysis (HTA) for locating admission requirements of graduate studies at New York University for the English department is required. (ii) A complete HTA for locating admission requirements for graduate studies at Harvard for the English Department is required. Discuss whether the solutions to (i) and (ii) can be modified to emphasize their common features and whether this would clarify the overall task description. P.S: This is Human Computer Interaction Topic, there are no more references to it. For the book you can refer: https://paragnachaliya.in/wp-content/uploads/2017/08/HCI_Alan_Dix.pdf, Chapter 15.
You need to compare a student's behavior when locating admission requirements of a university.
(i) A complete hierarchical task analysis (HTA) for locating admission requirements of graduate studies at New York University for the English department is required.
(ii) A complete HTA for locating admission requirements for graduate studies at Harvard for the English Department is required.
Discuss whether the solutions to (i) and (ii) can be modified to emphasize their common features and whether this would clarify the overall task description.
P.S: This is Human Computer Interaction Topic, there are no more references to it.
For the book you can refer: https://paragnachaliya.in/wp-content/uploads/2017/08/HCI_Alan_Dix.pdf, Chapter 15.
Write (and test) a C program to edge color a provided bipartite graph. The input to your program will be: a. , , and m, the numbers of left column vertices, right column vertices, and edges. and . b. m lines, each giving an edge: left column vertex, right column vertex. Left column vertices are numbered 0 . . . - 1. Right column vertices are numbered 0 . . . - 1. Duplicate edges will not occur. The output from your program will be: a. A trace of the processing. Each edge will be processed by either 1) using a color that is “free” at both incident vertices, or 2) using an alternating (a, b) path. For (1), simply indicate the free color that is used for the edge. For (2), indicate the colors (e.g. numbers) for a and b along with the vertices on the path. b. A list of the edges (input order) and the final color for each edge. 2. Submit your C code on Canvas before 3:45 p.m. on April 11. Your code must compile and execute on omega.uta.edu. Getting Started: 1. Bipartite edge coloring is discussed in Notes 11. Do not use the approach for general graphs, since the number of colors you may use is bounded by the degree (D) of the bipartite graph (not D + 1). 2. Assigned colors must be in the range 0 . . . D - 1. You will need to preprocess the edges to determine D. 3. Do not use backtracking instead of the alternating (a, b) path technique. 4. It is useful to have several tables. Rather than having a table of free colors for each vertex, it is useful to have a table that indicates for a given vertex and color the incident edge (if any) with that color.
Write (and test) a C program to edge color a provided bipartite graph.
The input to your program will be:a. , , and m, the numbers of left column vertices, right column vertices, and edges. and .
b. m lines, each giving an edge: left column vertex, right column vertex. Left column vertices are numbered 0 . . . - 1. Right column vertices are numbered 0 . . . - 1. Duplicate edges will not occur.
The output from your program will be:
a. A trace of the processing. Each edge will be processed by either 1) using a color that is “free” at both incident vertices, or 2) using an alternating (a, b) path. For (1), simply indicate the free color that is used for the edge. For (2), indicate the colors (e.g. numbers) for a and b along with the vertices on the path.
b. A list of the edges (input order) and the final color for each edge.
2. Submit your C code on Canvas before 3:45 p.m. on April 11. Your code must compile and execute on omega.uta.edu.
Getting Started:
1. Bipartite edge coloring is discussed in Notes 11. Do not use the approach for general graphs, since the number of colors you may use is bounded by the degree (D) of the bipartite graph (not D + 1).
2. Assigned colors must be in the range 0 . . . D - 1. You will need to preprocess the edges to determine D.
3. Do not use backtracking instead of the alternating (a, b) path technique.
4. It is useful to have several tables. Rather than having a table of free colors for each vertex, it is useful to have a table that indicates for a given vertex and color the incident edge (if any) with that color.
#include<stdio.h>
#include<stdlib.h>
//return 1 if two colors are sufficient. O not.
int canColorTwo(int vertices, int **graph){
int i,j;
//res will stores the i th vertex assigned color.
int *res = (int *)malloc(sizeof(int)*vertices);
//color will stres the i th color avilable or not.available means
0.otherwise 1.
int *color = (int *)malloc(sizeof(int)*vertices);
for(i 0;i<vertices;i++){
res[i] = -1;
color[i] = 0;
}
res[0] = 0;
//for each vertex in graph.
for(i =1;i<vertices; i++){
//making the colour to neighbour vertices as unavilable.
for(j =0;j<vertices;j++) {
if(graph[i][j] == 1&& res[j] ! = -1) {
color[res[j]] = 1;
}
}
//finding color.
for(j =0;j<vertices;j++) {
if(color[j] == 0 ) break;
}
// assigning color.
res[i] = j;
// reseting the color for the next vertoces.
for(j =0;j<vertices;j++) {
if(graph[i][j] == 1 && res[j]! = -1) color[res[j]] = 0;
}
}
//finding the max color are required to color the graph.
int max = res[0];
for(i = 0;i< vertices;i++) {
if(max< res[i]) max = res[i];
}
//return
if(max<2) return 1;
return 0;
}
int main() {
//reading data.
int vertices,edges,i,j;
scanf("%d",&vertices);
scanf("%d",&edges);
//creating adjecency graph matrix.
int **graph = (int **)malloc(vertices*sizeof(int));
for(i =0;i<vertices;i++) {
graph[i] = (int *)malloc(sizeof(int)&vertices);
}
//making all cells as -1. means no (vi,vi +1) connection.
for(i =0;i< vertices;i++)
for(j =0;j<vertices;j++)
graph[i][j] = -1;
//adding edjes in the graph.
for(i =0;i<edges;i++) {
int u,v;
scanf("%d%d",&u,&v);
graph[u][v] = 1;
graph[v][u] = 1;
}
//calling canColorTwo() if possible displaying two-color.otherwise no two-color.
if(canColorTwo(vertices,graph) == 1) {
printf("two-color");
}
else {
printf("no two-color");
}
return 0;
}
Write (and test) a C program to edge color a provided bipartite graph. The input to your program will be: a. , , and m, the numbers of left column vertices, right column vertices, and edges. and . b. m lines, each giving an edge: left column vertex, right column vertex. Left column vertices are numbered 0 . . . - 1. Right column vertices are numbered 0 . . . - 1. Duplicate edges will not occur. The output from your program will be: a. A trace of the processing. Each edge will be processed by either 1) using a color that is “free” at both incident vertices, or 2) using an alternating (a, b) path. For (1), simply indicate the free color that is used for the edge. For (2), indicate the colors (e.g. numbers) for a and b along with the vertices on the path. b. A list of the edges (input order) and the final color for each edge. 2. Submit your C code on Canvas before 3:45 p.m. on April 11. Your code must compile and execute on omega.uta.edu. Getting Started: 1. Bipartite edge coloring is discussed in Notes 11. Do not use the approach for general graphs, since the number of colors you may use is bounded by the degree (D) of the bipartite graph (not D + 1). 2. Assigned colors must be in the range 0 . . . D - 1. You will need to preprocess the edges to determine D. 3. Do not use backtracking instead of the alternating (a, b) path technique. 4. It is useful to have several tables. Rather than having a table of free colors for each vertex, it is useful to have a table that indicates for a given vertex and color the incident edge (if any) with that color.
Write (and test) a C program to edge color a provided bipartite graph.
The input to your program will be:a. , , and m, the numbers of left column vertices, right column vertices, and edges. and .
b. m lines, each giving an edge: left column vertex, right column vertex. Left column vertices are numbered 0 . . . - 1. Right column vertices are numbered 0 . . . - 1. Duplicate edges will not occur.
The output from your program will be:
a. A trace of the processing. Each edge will be processed by either 1) using a color that is “free” at both incident vertices, or 2) using an alternating (a, b) path. For (1), simply indicate the free color that is used for the edge. For (2), indicate the colors (e.g. numbers) for a and b along with the vertices on the path.
b. A list of the edges (input order) and the final color for each edge.
2. Submit your C code on Canvas before 3:45 p.m. on April 11. Your code must compile and execute on omega.uta.edu.
Getting Started:
1. Bipartite edge coloring is discussed in Notes 11. Do not use the approach for general graphs, since the number of colors you may use is bounded by the degree (D) of the bipartite graph (not D + 1).
2. Assigned colors must be in the range 0 . . . D - 1. You will need to preprocess the edges to determine D.
3. Do not use backtracking instead of the alternating (a, b) path technique.
4. It is useful to have several tables. Rather than having a table of free colors for each vertex, it is useful to have a table that indicates for a given vertex and color the incident edge (if any) with that color.
images
#include<stdio.h> #include<stdlib.h> //return 1 if two colors are sufficient. O not. int canColorTwo(int vertices, int **graph){ int inj; l/res will stores the i th vertex assigned color. int *res = (int *)malloc(sizeof(int)*vertices); //color will stres the i th color avilable or not.available means 0.otherwise 1. int *color = (int *)malloc(sizeof(int)*vertices); for(i = 0;i<vertices;i++){ res[i] = -1; color[i] = 0; } res[0] = 0; //for each vertex in graph. for(i = 1;i<vertices;i++){ //making the colour to neighbour vertices as unavilable. for(j = 0;j<vertices;j++){ if(graph[i][j] == 1 && res[j] != -1){ color[res[j]] = 1; } } //finding color. for(j = 0;j<vertices;j++){ if(color[j] == 0) break; } //assigning color. res[i] = 1; //reseting the color for the next vertices. for(j = 0;j<vertices;j++){ if(graph[i][j] == 1 && res[j] != -1) color[res[i]] = 0; } } //finding the max color are required to color the graph. int max = res[0]; for(i = 0;i<vertices;i++){ I=
if(max<reslil) max = res[i]; } //return if(max<2) return 1; return 0; } int main(){ //reading data. int vertices,edges,ij; scanf("%d",&vertices); scanf("%d",&edges); // creating adjecency graph matrix. int **graph = (int **)malloc(vertices*sizeof(int)); for(i = 0;i<vertices;i++){ graph[i] = (int *)malloc(sizeof(int)&vertices); } //making all cells as -1.means no (vi,vi+1) connection. for(i = 0;i<vertices;i++) for(j = 0;j<vertices;j++) graph[i][j] = -1; //adding edjes in the graph. for(i = 0;i<edges;i++){ - int u,v; scanf("%d%d",&u,&v); graph[u][v] = 1; graph[v][u] = 1; } // calling canColor Two() if posiible displaying two-color.otherwise no two-color. if(canColorTwo(vertices,graph) == 1){ printf("two-color"); } else{ printf("no two-color"); } return 0; }