Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The coding is done in C(I personally tried it with both eclipse and codeblocks) and I am extremely stuck and been at this for hours,

The coding is done in C(I personally tried it with both eclipse and codeblocks) and I am extremely stuck and been at this for hours, my 2nd university project at ASU.

my code so far

/CSE 355

//Ariz State Uni

#include

#include

void getY(int x[], int h[], int y[], int lenX, int lenH, int lenY );

int main(int argc, char* argv[]) {

int h[] = {2,1,0,-2,-1}; int x[] = {2, 1, 1, 3}; int i,lenX, lenH, lenY;

lenX = sizeof(x)/sizeof(int);

lenH = sizeof(h)/sizeof(int);

lenY = lenX + lenH - 1; //C + D -1

int* y = malloc( lenY * sizeof(int));

getY(x, h, y, lenX, lenH, lenY);

//display matrix y

printf(" ");

for(i=0; i

printf(" %d" , y[i]);

//REPEAT

int h2[] = {4,3,2,1,0,-2,-1};

int x2[] = {-6,-5,-2,-1,1,3};

lenX2 = sizeof(x2)/sizeof(int);

lenH2 = sizeof(h2)/sizeof(int);

lenY = lenX2 + lenH2 - 1; //C + D -1

return 0;

}

void getY(int x2[], int h2[], int y[], int lenX2, int lenH2, int lenY ) {

// where I'm stuck I have a few ideas but none of them worked out for me.

}

Requirements:

1. create x(k) (i.e., flip x(k) ): From x(k) = {2, 1, 1, 3}, create x(k) =

{3, 1, 1, 2}, must flip the array

2. create a 2d matrix of size C D + 1

3. You have to copy flipped sequence into each row of 2d matrix that you have just created in step 2. Need to understand that x stops at k=3, so when it is indeed flipped, it starts at k = 3. Also, see that the last index for h is k = 4, so the sequence must slick n slide from k = 3, to k = 4 or 4 (3) = 7 shifts, but including the first, there are 7 + 1 = 8 placements required here.

4.copy h into another array of size C D + 1 = 8, starting from k = 3, leaving zeros in empty cells.

5. multiply x by h, row by column, keeping the sum

Tried it myself a first few rounds getting terrible complication errors. Done in C programming, some people did it in C++ in my class. Mine is in C.

Example for step 3: the example is essentially matrix multiplication bringing backs some linear algebra action. The vector x(k) is transformed using x(-k). the x(-k) sequence is then shifted from left to right. Must understand that the left wing begins at k =3, and ends at k=4. Resulting in 4-(-3) + 1 =8. as final answer

Expert Answer

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

1. Organize and support your main points

Answered: 1 week ago

Question

3. Move smoothly from point to point

Answered: 1 week ago

Question

5. Develop a strong introduction, a crucial part of all speeches

Answered: 1 week ago