Question

In: Computer Science

Create a C++ project in visual studio. You can use the C++ project that I uploaded...

Create a C++ project in visual studio.

You can use the C++ project that I uploaded to complete this project.

1. Write a function that will accept two integer matrices A and B by reference parameters, and two integers i and j as a value parameter. The function will return an integer m, which is the (i,j)-th coefficient of matrix denoted by A*B (multiplication of A and B). For example, if M = A*B, the function will return m, which is equal to M[i][j].

Explain the time complexity of this function inside of the code as a comment.

2. Write a function that will accept two integer matrices C and D by reference parameters. The function will compute the transpose of C and store it in D. For your information, the transpose of matrix C is D, where D[j][i] = C[i][j].

Explain the time complexity of this function inside of the function code as a comment.

3. Write a function that will accept one integer matrix E and one column vector F by reference parameters, and one integer I as a value parameter. The function will return an integer v, which is the i-th coefficient of row vector denoted by E*F (multiplication of E and F). For example, if V = E*F, the function will return v, which is equal to V[i].

Explain the time complexity of this function inside of the function code as a comment.

Solutions

Expert Solution

//Question1:-
//rename arr1->A and arr2->B
//time complexity for the loop is n^3 as wee use 3 loops in it
#include <iostream>
int print(int arr1[3][3],int arr2[3][3],int i,int j) 
{ 
    int matrix[i][i];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            int sum=0;
            for(int k=0;k<3;k++){
                sum=sum+(arr1[i][k]*arr2[k][j]);
            }
            matrix[i][j]=sum;
        }
    }
    for (int x = 0; x< 3; x++){ 
      for (int y = 0; y < 3; y++){ 
            std::cout<<matrix[x][y]<<"\t";
      }
  std::cout<<"\n";
    }
    return matrix[i][j];
} 
  
int main() 
{
    int i=1,j=2;
    int arr1[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
    int arr2[3][3] = {{3,4,5,},{7,5,4},{5,8,2}};
    int m=print(arr1,arr2,i,j);
    if(m!=0)
        std::cout<<m<<"\t"<<"Element found";
    else
        std::cout<<"\t"<<"Element not found";
    return 0; 
} 
//Question2:-
//time complexity for the loop is n^2 as wee use 2 loops in it

#include <iostream>
void print(int C[3][3],int D[3][3]) 
{ 
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            D[i][j]=C[j][i];
        }
    }
} 
  
int main() 
{
    int C[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
    int D[3][3];
    std::cout<<"Before Transpose"<<"\n";
    for (int x = 0; x< 3; x++){ 
      for (int y = 0; y < 3; y++){ 
            std::cout<<C[x][y]<<"\t";
      }
    std::cout<<"\n";
    }
    print(C,D);
    std::cout<<"After Transpose"<<"\n";
    for (int x = 0; x< 3; x++){ 
      for (int y = 0; y < 3; y++){ 
            std::cout<<D[x][y]<<"\t";
      }
    std::cout<<"\n";
    }
} 

I hope you like the solution if you do so then press that thumbs up button to support.


Related Solutions

Create a C# .NET Core Console project in Visual Studio. (This is the same kind of...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of project we have been doing all semester.) Do all of the following in the Program class. You do not need to add any other classes to this project. 2. If it exists, remove the Console.WriteLine(“Hello World!”); line that Visual Studio created in the Program class. 3. At the very top of the Program.cs page you should see using System; On the empty line below...
ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this...
ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this part of the assignment, you are required to create a C# Console Application project. The project name should be A3<FirstName><LastName>P2. For example, a student with first name John and Last name Smith would name the project A1JohnSmithP2. Write a C# (console) program to calculate the number of shipping labels that can be printed on a sheet of paper. This program will use a menu...
C# ( asp.net ) 2019 Visual Studio I have a dropdown where you can select (...
C# ( asp.net ) 2019 Visual Studio I have a dropdown where you can select ( integer, string, date ) After selecting the desired dropdown option, user can input a list of inputs. For example; for integer: 2,5,7,9,1,3,4 And then , I have a 'sort' button Can you please help me with the code behind for sorting them( For integer, string, and date ) Thank you.
Create a new “Area” project. Create a new Visual Studio Project and call it “Area”. This...
Create a new “Area” project. Create a new Visual Studio Project and call it “Area”. This project will be used to calculate the area of certain figures, like circles, squares and rectangles. So add a title to the Form. The Form Title should say “Area”. Also add 3 labels, 3 Buttons, 3 Textboxes and 3 RadioButtons. The 3 Buttons should be near the bottom of the Form and say “Calc Area”, “Clear” and “Exit”. Make sure to give all your...
Create a Visual Studio console project (c++) containing a main() program that declares a const int...
Create a Visual Studio console project (c++) containing a main() program that declares a const int NUM_VALUES denoting the array size. Then declare an int array with NUM_VALUES entries. Using a for loop, prompt for the values that are stored in the array as follows: "Enter NUM_VALUES integers separated by blanks:" , where NUM_VALUES is replaced with the array size. Then use another for loop to print the array entries in reverse order separated by blanks on a single line...
I need the code for following in C++ working for Visual studio please. Thanks Use a...
I need the code for following in C++ working for Visual studio please. Thanks Use a Struct to create a structure for a Player. The Player will have the following data that it needs maintain: Struct Player int health int level string playerName double gameComplete bool isGodMode Create the 2 functions that will do the following: 1) initialize(string aPlayerName) which takes in a playername string and creates a Player struct health= 100 level= 1 playerName = aPlayerName gameComplete = 0...
In Visual Studio in C#, you will create a simple calculator that performs addition, subtraction, multiplication,...
In Visual Studio in C#, you will create a simple calculator that performs addition, subtraction, multiplication, and division. Your program should request a numerical input from the user, followed by the operation to be performed, and the second number to complete the equation. The result should be displayed to the user after each equation is performed. For example, if the user performs 3+3, the program should display 6 as the result. The program should continue running so the user can...
In visual Studio C++ Create a program that uses a for loop to input the high...
In visual Studio C++ Create a program that uses a for loop to input the high temperature, and low temperature for each day of the week. The high and low will be placed into two elements of the array. For each loop the high and low will be placed into the next set of elements of the array. After the temps for all seven days have been entered into the array, a for loop will be used to pull out...
USE VISUAL STUDIO/VB In this assignment, you will create an array of ten elements, one for...
USE VISUAL STUDIO/VB In this assignment, you will create an array of ten elements, one for name, one for hours worked,and the last for hourly rate. The arrays will receive the information from inputs from the screen.For example, you will ask the following three questions: a) Employee name: b) Hours worked: c) Hourly rate: After you have received all ten records and have inserted them into the array, you will then calculate the hourly rate times the hours worked to...
Create a new Visual Studio console project named assignment042, and translate the algorithm you developed in...
Create a new Visual Studio console project named assignment042, and translate the algorithm you developed in Assignment 04.1 to C++ code inside the main() function. Your program should prompt for a single 9-digit routing number without spaces between digits as follows: Enter a 9-digit routing number without any spaces: The program should output one of: Routing number is valid Routing number is invalid A C++ loop and integer array could be used to extract the routing number's 9 digits. However...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT