Exercise 1:Computer Addresses Management Numeric addresses for computers on the wide area network Internet are composed
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Exercise 1:Computer Addresses Management Numeric addresses for computers on the wide area network Internet are composed
Exercise 1:Computer Addresses Management Numeric addresses for computers on the wide area network Internet are composed of four parts separated by periods of the form xx.yy.zz.mm, where xx,yy, zz, and mm are positive integers. Locally computers are usually known by a nickname as well. You are designing a program to process a list of internet addresses, identifying all pairs of computers from the same locality (i.e, with matching xx and yy component). (a) Create a C structure called InternetAddress with fields for the four integers and a fifth component to store an associated nickname. (b) Define a function, ExtractinternetAddress, that extracts a list of any number of addresses and nicknames from a data file whose name is provide as argument, and returns a dynamically allocated array that holds the indicated number of internet addresses (represented in InternetAddress) objects) retrieved from the file. The first line of the file should be the number of addresses that follow. Here is a sample data set: 4 111.22.3.44 555.66.7.88 111.22.5.88 234.45.44.88 plato gauss mars ubuntu (c) Define a function Common Locality that receives as arguments the array constructed in a) and the number of internet addresses, and displays a list of messages identifying each pair of computers from the same locality. In the messages, the computers should be identified by their nicknames. Here is a sample message: Machines plato and mars are on the same local network. (d) Define the main function that prompts the user to enter the name computers.txt) of the file containing the Computer addresses as escribed in (b) and displays a list of messages identifying all pair of computers from the same locality. Exercise 2: Minimization of scheduling conflicts The transpose of a matrix is formed by interchanging the matrix's rows and columns. Thus the transpose of matrix of 2 4 6 8 is A' = 2 6 10 A= 10 12 4 8 12 The organizers of an in-house Cloud Computing conference for small consulting company are trying to minimize scheduling conflicts by scheduling the most popular presentations at different times. First the planners survey the ten participants to determine which of the five presentations they want to attend. Then they construct a matrix A in which a 1 in entry ij means that participant i wants to attend presentation j. The following table and matrix (A) give information about the participation. Participant Presentation 1 2 3 4 5 [10101 1 10 1 0 1 10 00111 2 0 0 1 00111 10000 3 1 io оооо 01101 4 0 1 0 1 ооооо 5 0 0 0 0 0 6 i10 00 0 0 0 1 0 1 0 7 7 0 0 1 0 1 0 0 1 0 1 0 8 0 1 1010 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1 0 1 10 0 0 0 1 0 10 2 1 It means matrix A = 1 0 0 0 0 0 0 0 1 0 0 0 1 1 0 9 0 1 0 0 Next the planners calculate the transpose of A(A) and the matrix product of A' X A. In the resulting matrix, entry ij is the number of participants wishing to attend both presentation i and presentation j. We then have 4 1 2 0 2 1 31 1 1 A' XA = 2 1 5 1 5 ' 1 5 0 1 1 3 1 2 1 5 1 5 notice that B=A' x A is symmetric ( Bij = By for all i, j), so the entries below the main diagonal (entries ij where i < j) need not be calculated. If we supply zeros for the unnecessary entries, the resulting matrix is termed upper triangular matrix. The entries on the main diagonal (B:) represent the total participants wanting to attend presentation i. (a) Write a C function TotalPart that creates the matrix A of participants preferences, from data received from data read from a file as sequence of couples of integers, where the first couple is such that the first number represent the number of presentation and the second number represents the number of participants and the rest of couples are such that for each couple the first number represents the participant and the second number represents one of the presentations he/she wants to attend; this means a participant can appear several times in the sequence if he/she wants to attend more than one presentation. For example, the file containing the sequence 3 4 1 2 3 4 1 4 3 1 2 4 will produce 0101 0 1 0 1 A=0001 1001 (b) Given a matrix T with n rows and p columns and a matrix S with p rows and 2 columns, if the product T x S is equal to P-1 C then Cj = Tik Skj, where i = 0,1.....n-1 and j = 0,1,...,q-1. Given the matrix of preferences A write the function ComputeAtA that computes A' XA and saves it in another matrix C. and displays how many participants wish to attend each conference. (c) Write a C function AvoidBad Schedule that receives as argument the matrix A of preferences, finds the three largest numbers in the entries above the main diagonal of A' XA, and displays on the screen up to three pairs of presentations that the conference committee should avoid scheduling at the same time. You will display fewer than three pairs if one or more) of the three largest number is 1. (d) Provide a driver program that prompts the user to enter the name (scheduling.txt) the file containing the attendance to presentations sequence as described in (a), and displays the pairs of presentations to be avoided. TO SUBMISSION PROCEDURE Your submission may contain: • Your source code files • • A two page report on your assignment Report The report should contain the following sections: 1. list of files: list of each file contained in your submission. 2. usage: This section should explain how to use your script. 3. implementation: this section should provide a brief description to your script's organization and its implementation. 4. Bugs: This section should mention any known bugs. If you are unaware of any bugs, simple place "NONE" under this heading. 2 of 2
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!