A Gnutella topology looks like a balanced ternary tree with 4 levels of nodes, i.e., peers, as shown in the picture below. Thus, there is one root at Level 1, which has 3 children at Level 2, which each have 3 children at Level 3, which in turn each have 3 children at Level 4 – thus, there are a total of 40 nodes.If the originating node of the Query is a leaf (Level 4 node), what is the minimum TTL to ensure all nodes in the system receive the Query?
Answers
Search Programiz
C Program to Find Transpose of a Matrix
C Program to Find Transpose of a Matrix
In this example, you will learn to find the transpose of a matrix in C programming.
To understand this example, you should have the knowledge of the following C programming topics:
C Arrays
C Multidimensional Arrays
The transpose of a matrix is a new matrix that is obtained by exchanging the rows and columns.
In this program, the user is asked to enter the number of rows r and columns c. Their values should be less than 10 in this program.
Then, the user is asked to enter the elements of the matrix (of order r*c).
The program below then computes the transpose of the matrix and prints it on the screen.
Program to Find the Transpose of a Matrix
#include <stdio.h>
int main() {
int a[10][10], transpose[10][10], r, c, i, j;
printf("Enter rows and columns: ");
scanf("%d %d", &r, &c);
// Assigning elements to the matrix
printf("\nEnter matrix elements:\n");
for (i = 0; i < r; ++i)
for (j = 0; j < c; ++j) {
printf("Enter element a%d%d: ", i + 1, j + 1);
scanf("%d", &a[i][j]);
}
// Displaying the matrix a[][]
printf("\nEntered matrix: \n");
for (i = 0; i < r; ++i)
for (j = 0; j < c; ++j) {
printf("%d ", a[i][j]);
if (j == c - 1)
printf("\n");
}
// Finding the transpose of matrix a
for (i = 0; i < r; ++i)
for (j = 0; j < c; ++j) {
transpose[j][i] = a[i][j];
}
// Displaying the transpose of matrix a
printf("\nTranspose of the matrix:\n");
for (i = 0; i < c; ++i)
for (j = 0; j < r; ++j) {
printf("%d ", transpose[i][j]);
if (j == r - 1)
printf("\n");
}
return 0;
}
Answer:
39
Explanation:
if we don’t include originate and travel to each node till ttl=0