A square matrix in which all the entries below the main diagonal are zero is called upper triangular. Write a function IsMatrixUpperTriangular which takes a matrix and returns true if the matrix is upper triangular and false otherwise. For example, matrix A shown below is upper triangular while matrix B is not upper triangular.
Q: Write a function called Replace All that cerpts two parameters a matrix of 100 elements of type…
A: We need to write the code that do the following operations: Replace every positive matrix element…
Q: Write a python function, matrix_multiplication, that takes two integer matrices, A and B, and…
A: First we will input the row and column of matrix A. Then we will input the row and column of matric…
Q: Write a C function that, given a square matrix of floats, finds the diagonal with maximum average…
A: Solution:-- Given question is:-- To write a code in C language that will calculate the average…
Q: Diinonsions of ihe Matrix The e in t unrst unieiwite:su. te slape and size of a matrix. Function…
A: Length:- Here i the code to find the length of the matrix A = rand(5) * 10 L = length(A) A is the…
Q: Write a function called "Replace_All" that accepts two parameters: a matrix of 10x20 elements of…
A: Declare a function with return type void
Q: ++ Given an integer matrix of size M × N. Find the number of the first of its columns containing an…
A: #inсlude <bits/stdс++.h>using nаmesрасe std;int соuntNegаtive(int M[][4], int n, int…
Q: A square matrix in which all the entries below the main diagonal are zero is called upper…
A: Given: Matrix A = { {-1, 2, 7, 0}, {0, 5, 0, -1}, {0, 0,…
Q: The square root of 1.5 is obtained by finding the positive root of the quadratic equation 10)-1²-15…
A: First we need to create a function to find the sign of an integer. After create a bisection root…
Q: Re-write the following program by using functions Note: - the program is for reading and printing…
A: Given code: #include<iostream>using namespace std; int main(){ int x[3][3], A[9], B[9],…
Q: Write a function that diagonally orders numbers in a n x n matrix, depending on which of the four…
A: Function plan: Create an array, temp of size size. Insert another array of size size for each index…
Q: Write a function called "Replace_All" that accepts two parameters: a matrix of 10x20 elements of…
A: If Number is positive, replace 5 If Number is negative, replace -5 If number is 0, replace 0
Q: Write a function called "ReplaceALL" that accepts two parameters: a matrix of 20x10 elements of type…
A: Source Code: #include <bits/stdc++.h> #define ROW 20#define COL 10using namespace std;void…
Q: 1. Polynomial Function: Given the cubic polynomial function f(x) = ax' + bx + cx +d Write a C++…
A: I have given solution in c++ below.
Q: Write a function definition for a function named fiboArray to do the following: a. Accept an integer…
A: The answer given as below:
Q: (d) Create the matrix A, whose first row is equal to x, whose second row is a line of ones, and…
A: - We have to work with matrix in python with the help of numpy.
Q: Q: Write a program in Qbasic language to read and print the the numbers of the one dimensional…
A: Declaring number of type integer Getting input from user Calculating the summation of first three…
Q: Write a function that takes a matrix of order 3 and prints the transpose of it. The transpose should…
A: Introduction of the program: The C++ program takes input from the user for the 3x3 matrix and then…
Q: Write a function insertElement (consisting of 3 parameters: integer vector a, position pos and…
A: #include <iostream> #include <vector> using namespace std; void…
Q: Write a function named lowerLeftQuarter that takes one argument, a matrix. The function then returns…
A: Since no programming language is mentioned, I am using matlab Code: lowerLeftQuarter([1 2 3 4;5…
Q: An incomplete Sudoku configuration in terms of a 9x9 2-D square matrix(sudoku[][]) is passed as a…
A: Complete the function in C++ to check whether the 9*9 matrix passed to the function is valid sudoku…
Q: Given a matrix of characters A of sizen x m and a string s, write a C function that counts how many…
A: #include<stdio.h> #include<string.h> #define MAXM 100 //function count int count(char…
Q: Write a function coplanar0, that takes as parameters four 3D vectors representing points, and…
A: // C++ program to check whether if 4 points in a 3-D plane are Coplanar…
Q: Q7. You are in a party of N people, where there may be a celebrity also. If such a person is present…
A: You are in a party of N people, where there may be a celebrity also. If such a person is present in…
Q: An incomplete Sudoku configuration in terms of a 9x9 2-D square matrix(sudoku[00) is passed as a…
A: The primary idea is to look at the following points to see if each row, column, and 33 box is valid…
Q: 6. Write a function EXPCR( ) which accepts a 3 × 1 vector x = the 3 x 3 rotation matrix which…
A: Hi Dear!! Please like...It is more valuable 6) To define multiplication between a matrixAA and a…
Q: For this assignment you will be replicating the game of Roshambo (aka rock, paper, scissors). First,…
A: Solution:-- 1)The given question has required for the solution with the program in the R language…
Q: Write a function called hw3_problem2 that takes an at most two-dimensional matrix A as its sole…
A: Algorithm : Step 1 : define the function Step 2 : initialize maximum variable with first matrix…
Q: SEARCH IN MATRIX You are give a matrix (a list of lists) of DISTINCT integers and a target number.…
A: Below I have provided Python Programming . Also, I have attached the screenshot of the code and…
Q: Please help me in this fast. I have to write a C++ function to which a vector is passed as…
A: Write a C++ function to which a vector is passed as an argument and it returns the maximal…
Q: A C_++ program for Solving system of linear equations with two variables using Cramer’s rule. In…
A: #include <iostream>using namespace std; int main() { int d[2][2]; cout<<"Input…
Q: Write a function to find the norm of a matrix. The norm is defined as the square root of the sum of…
A: The norm is defined as the square root of the sum of squares of all elements in the matrix We need…
Q: could you please solve this question as Ocaml programming language ? thanks Sliding tiles…
A: Step 1 Introduction to OCAML Language It is defined as a general purpose programming language with…
Q: Write a program in C++ which takes two 4 x 4 matrices as input from the user and displays the…
A: Program: //header files #include<iostream> #include<conio.h> //main body int main()…
Q: Suppose that a company's employee data is stored in a matrix like the one in the image example:…
A: As no programming language is mention. So I am using Python to code this question.
Q: Write a function to find the norm of a matrix using pointers. The norm is defined as the square root…
A: The C code is given below with code and output screenshot Happy Coding?
Q: Given a 2D array of integers where each row represents the three exam grades for a specific student:…
A: Logic: Accept marks from the user. call the function to find high gpa. Compare gpa of every student…
Q: Q2) Write down a C/C++ function that increases the salary of the given employee 10 by 20 percent…
A: Here is the c++ code: See below steps for code:
Q: Write a function called "Replace All" that accepts two parameters: a matrix of 10x20 elements of…
A: #include <bits/stdc++.h>#define ROW 10#define COL 20using namespace std; void ReplaceAll(int…
Q: caml programming 1. Create a type slidingTile, consisting of a char matrix and two integers x…
A: Source Code -> NOTE: right = R left = L down = D up = U I have used ' * ' instead of 0 .
Q: 1. (Random Integer Matrices) In this question, you'll make a function which produces three random…
A: the answer is given below: three_mats function
Q: 1. Write a function called hwd_probleml that takes two inputs: a vector v and a positive integer…
A: Solution: Given,
Q: Given two vectors of integers (either positive, negative or zeros) v, and vz of length d, and d,…
A: #include<stdio.h> void swap(int *xp, int *yp) { int temp = *xp; *xp = *yp; *yp =…
Q: Take a screenshot of your output.
A: FOR GIVEN PROGRAM - #include <iostream>#include <vector>using namespace std;struct rpair…
Q: 4.b. Write a user defined function to find the sum of elements of m*n matrix and finally returns the…
A: The program is written in C #include <stdio.h>int m,n,i,j;int sum(int a[m][n]){ int s=0;…
Takes input from the user for the matrices. Write a C++ code.
Step by step
Solved in 5 steps with 3 images
- Hi, OCaml programming 1. Create a type slidingTile, consisting of a char matrix and two integers xand y. The integers x and y are the coordinates of an empty tile. 2. Create a function val slide : slidingTile -> int -> int -> slidingTile = <fun> that given a slidingTile and two integers, that represent a location in thematrix, it slides the tile from the specified location to the empty tile, thenreturns the altered slidingTile. If provided location is not adjacent to theempty tile, or out of bounds, then return the slidingTile unaltered. 3. Create a function val print_tile : slidingTile -> unit = <fun> that prints a slidingTile on screen with the corresponding characters fromthe matrix. However, print an empty space where the empty tile is instead.could you please solve this question as Ocaml programming language ? thanks Sliding tiles 1.Create a type slidingTile, consisting of a char matrix and two integers x and y. The integers x and y are the coordinates of an empty tile. 2.Create a function val slide : slidingTile -> int -> int -> slidingTile = <fun> that given a slidingTile and two integers, that represent a location in the matrix, it slides the tile from the specified location to the empty tile, then returns the altered slidingTile. If provided location is not adjacent to the empty tile, or out of bounds, then return the slidingTile unaltered. 3.Create a function val print_tile : slidingTile -> unit = <fun> that prints a slidingTile on screen with the corresponding characters from the matrix. However, print an empty space where the empty tile is instead.Interesting, intersecting def squares_intersect(s1, s2): A square on the two-dimensional plane can be defined as a tuple (x, y, r) where (x, y) are the coordinates of its bottom left corner and r is the length of the side of the square. Given two squares as tuples (x1, y1, r1) and (x2, y2, r2), this function should determine whether these two squares intersect, that is, their areas have at least one point in common, even if that one point is merely the shared corner point when these two squares are placed kitty corner. This function should not contain any loops or list comprehensions of any kind, but should compute the result using only integer comparisons and conditional statements. This problem showcases an idea that comes up with some problems of this nature; it is actually far easier to determine that the two squares do not intersect, and negate that answer. Two squares do not intersect if one of them ends in the horizontal direction before the other one begins, or if the same…
- C++ Given an integer matrix of size M × N. Find the number of the first of its columns containing an equal number of positive and negative elements (zero elements of the matrix must be ignored). If there are no such columns, then print 0. Write a function to solve this problem. void max_each_column(int a[20][20], int n, int m) 3 3 1 2 -3 4 0 3 7 -8 0 Output: 1Write a function called number_matrix(r,c) that takes two parameters r and c and PRINTS ON THE SCREEN a matrix of numbers as follows: 1 2 3 4 5 .... 2 3 4 5 6 .... 3 4 5 6 7 .... ... In this pattern, each row contains c numbers and there are r rows. For example, number_matrix(4,3) results in: 1 2 3 2 3 4 3 4 5 4 5 6Write a function called hw3_problem1 that takes a matrix A of positive integers as its sole input. If the assumption is wrong, the function returns an empty matrix. Otherwise, the function doubles every odd element of A and returns the resulting matrix. Notice that the output matrix will have all even elements. For example, the call B = hw3_problem1([1 4; 5 2; 3 1], will make B equal to [2 4; 10 2; 6 2]. You are not allowed to use loops.
- (a) Write a function matrix_multiply(mat1, mat2) that takes two matrices and returns the result of the matrix multiplication between mat1 and mat2. If the two matrices are not compatible with multiplication, then None should be returned. (b) Write a function print_sums(list1, list2) that takes two equal-length lists of numbers and prints all the sums of the corresponding elements. Thus the first line is the sum of the first element of list1 and the first element of list2, the second line is the sum of the second elements, and so on.For this assignment you will be replicating the game of Roshambo (aka rock, paper, scissors). Please answer both parts a and b of the following question below. Show the R code in your answer and annotate all parts of the code. a.) First, you need to come up with a strategy to win the game. Write a function in R that takes in a vector of past plays for your opponent (each play should be represented as "R", "P", or "S") and outputs the next move ("R", "P", or "S"). Your strategy should at least depend on the last two moves used, but you should return a random move if there is not enough past history to use the strategy. b.) Now, play your strategy against a random player who uses rock, paper, or scissors with 1/3 probability each. Who wins the most rounds after 100 rounds of play? Write a function in R.in c++ please Write a function called Replace All that cerpts two parameters a matrix of 100 elements of type inter and an interval y. The function must - Replace every positive matrix element by the values +5and Replace every negative matrix element by the value - 5 and - Replace every mero try the value y.
- Write a function named lowerLeftQuarter that takes one argument, a matrix. The function then returns the lower left quarter of the input matrix as a new matrix. For example, if the input is 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 Then the following matrix should be returned. 0 1 4 5 If the input is 1 2 3 5 7 9 0 5 Then the following matrix should be returned. 7 9Ocaml programming 1. Create a type slidingTile, consisting of a char matrix and two integers xand y. The integers x and y are the coordinates of an empty tile. 2. Create a function val slide : slidingTile -> int -> int -> slidingTile = <fun> that given a slidingTile and two integers, that represent a location in thematrix, it slides the tile from the specied location to the empty tile, thenreturns the altered slidingTile. If provided location is not adjacent to theempty tile, or out of bounds, then return the slidingTile unaltered. 3. Create a function val print_tile : slidingTile -> unit = <fun> that prints a slidingTile on screen with the corresponding characters fromthe matrix. However, print an empty space where the empty tile is instead.IN PYTHON! Given an n×n matrix A and n×1 right-hand side b, write a function that carries out q iterations of the Gauss elimination outer loop (without pivoting), where q is an integer between 1 and n, and returns the resulting augmented matrix with all below-diagonal elements transformed to zero in the left-most q columns. ##The code format given below may help # def gaussq (A, b, q): '''Apply Gauss elimination (without pivoting) to first q columns of a given linear system Inputs: A, coefficient matrix, size n by n b, vector of constants, n by 1 q, number of columns to apply Gauss elimination to, an integer between 1 and n Output: Aa, augmented matrix with all below-diagonal elements transformed to zero in the left-most q columns, n by n+1 #to check the work