Subject: Data Structures and Algorithms, C++ please help
in this take-home quiz. need full marks please double-check answers
to make sure it's correct and complete. will give
upvote.
Question 18 (3 Marks) Suppose we have a square matrix: int matrix[n] [n], where n>0. Can you briefly describe what the code below does (word limit: 100)? You may use an example and draw a figure to illustrate your idea if you want. for (int x = n-1; x > -1; x--) { for (int y = 0; y <n; y++) { if (x < n-1 && y > 0) { matrix [x][y] += std::min (matrix [x+1] [y], matrix [x] [y-1]); } else if (x < n-1) { matrix [x] [y] += matrix [x+1] [y]; } else if (y > 0) { matrix [x][y] += matrix[x] [y-1]; } } std::cout << matrix [0] [n-1] << std::endl;
Subject: Data Structures and Algorithms, C++ please help in this take-home quiz. need full marks please double-check ans
-
- Posts: 43759
- Joined: Sat Aug 07, 2021 7:38 am