![Suppose that an array A of n 1 numbers is given. We want to create a n x n matrix B such that, for 0 i<j<n, Bli.j] AIk] = Ali](http://img.homeworklib.com/questions/d2647030-2307-11eb-b5b1-693589bc61d9.png?x-oss-process=image/resize,w_560)
Can someone please help me in solving question in attached image. Thanks
this program in c++ #include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n],c[n][n],b[n][n],i,j;
for(i=0;i<n;i++) //This for loop run for n times
{
cin>>a[i];
}
for(i=0;i<n;i++) //This for loop run for n times
{
int sum=0;
for(j=0;j<n;j++) //This for loop run for n times
{
if(i<=j)
{
sum=sum+a[j];
c[i][j]=sum;
}
else
c[i][j]=0;
}
}
for(i=0;i<n;i++) //This for loop run for n times
{
for(j=0;j<n;j++) //This for loop run for n times
{
if(i>=j)
b[i][j]=0;
else
b[i][j]=c[i][j];
}
}
for(i=0;i<n;i++) //This for loop run for n times
{
for(j=0;j<n;j++) //This for loop run for n times
{
cout<<b[i][j];
}
cout<<endl;
}
return 0;
}

Can someone please help me in solving question in attached image. Thanks Suppose that an array...
Suppose you have an array S indexed from 1 to n which contains n numbers, not in any particular order, and you wish to count how many times a given number x occurs in S. Consider the recursive algorithm below for this which finds the number of occurrences of x in the index range i...j in S. Of course, solving the problem would involve an initial call to the algorithm for the range 1.n: int CountOccur (int i,j) { int...
CAN SOMEONE HELP ME AND WITH SOLVING AND EXPLAINING IT TO ME PLEASE? Short Answer Question 2 - The Display [10 marks] Rather than showing numbers, we want to design our 7-segment display for letters. Design a circuit to decode our binary representation of each pressed key into the closest approximation of the ASCII letter (5 = A, 6 = B, 7 = C, 8 = D). Each segment of the display (a-g) is an LED that turns on with...
QUESTION 3 (10 Marks) Suppose you are given an array A[0..n 1 of integers, each of which may be positive, negative, or zero. A contiguous subarray A|i..j] which includes all the items starting at array index i and ending at array index j is called a positive interval if the sum of its entries is at least zero. For example let A-{-1, 3,-5, 2, 0,-4, 3,-6,-2). Ten A[3, 6) is a positive interval since its sum is 2+0+(-4)+3-1, but Al4,7isnot...
Can someone please help me understand the correct steps in
solving this Number Theory practice question? Thank you!
Prove that the sequence Bn we have...
n- j Bn = 1 + rt j-1 we have Bn F+1 for neN.
(a) Suppose we want to solve the linear vector-matrix equation Ax b for the vector x. Show that the Gauss elimination algorithm may be written bAbm,B where m 1, This process produces a matrix equation of the form Ux = g , in which matrix U is an upper-triangular matrix. Show that the solution vector x may be obtained by a back-substitution algorithm, in the form Jekel (b) Iterative methods for solving Ax-b work by splitting matrix A into two...
the question from the course COMP 4040 that Analysis of
Algorithms
if you want to answer it by code please use C or C++
5. Algorithm Design (20 points) Input: array A contains n distinct numbers from 1 to n, in arbitrary order. Output: number of inversions (defined as the number of pair(i, j) of array indices with i < j and A[i] > Aj]) (a) (5 points) What array with elements from the set {1, 2, ..., n) has...
An m×n
array A
of real numbers is a Monge array if for all i,j,k,
and l
such that 1≤i<k≤m
and 1≤j<l≤n
, we have
>A[i,j]+a[k,l]≤A[i,l]+A[k,j]>
In other words, whenever we pick two rows and two columns of a
Monge array and consider the four elements at the intersections of
the rows and columns, the sum of the upper-left and lower-right
elements is less than or equal to the sum of the lower-left and
upper-right elements. For example, the following...
Suppose you are given an array A holding n distinct integers (negative values are allowed) in sorted order; in other words, A[i] < A[i + 1] for each i ∈ [0, n − 2]. We say the ith element is self referential if A[i] = i. Design an O(log n) time algorithm to determine if there is a self referencial element in the array. Your solution must include a) Statement of your algorithm in plain English. (Pseudo-code is optional.) b)...
Suppose we are given two sorted arrays (nondecreasing from index 1 to index n) X[1] · · · X[n] and Y [1] · · · Y [n] of integers. For simplicity, assume that n is a power of 2. Problem is to design an algorithm that determines if there is a number p in X and a number q in Y such that p + q is zero. If such numbers exist, the algorithm returns true; otherwise, it returns false....
l
have posted it a few times before but didnt get a satisfactory
answer. kindly help me by answering in pseudo code
2 Knapsack Problem În al Knapsack problem. given n items(11-12. . . . . 1"} with weight {w1·W2. . . . . ux) and value (n 2, .., nJ, the goal is to select a combination of items such that the total value V is maximized and the total weight is less or equal to a given capacity...