Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the C++ code INTO ALGORITHM FORMAT (code below and format wanted is under

ID: 3710482 • Letter: W

Question

Write the C++ code INTO ALGORITHM FORMAT (code below and format wanted is under it)

code:

#include<bits/stdc++.h>
using namespace std;
int numberOfPaths(int m, int n)
{
int count[m][n];
for (int i = 0; i < m; i++)
count[i][0] = 1;
for (int j = 0; j < n; j++)
count[0][j] = 1;
for (int i = 1; i < m; i++)
{
for (int j = 1; j < n; j++)

count[i][j] = count[i-1][j] + count[i][j-1];

}
return count[m-1][n-1];
}
int main()
{
cout << numberOfPaths(8, 8);
return 0;
}

ALGORITHM TYPE OF FORMAT: (just an example)

ALGORITHM AlgorithmFormat (T[0..n – 1], P[0..m – 1])

                        //Implements brute-force string matching

//Input: An array T[0..n – 1] of n characters representing a text and

//           an array P[0..m – 1] of m characters representing a pattern

//Output: The index of the first character in the text that starts a

//              matching substring or –1 if the search is unsuccessful

for i ß 1 to n - m do

j ß 0

while j < m and P[j] = T[i + j] do

            j ß j + 1

if j = m return i

return 0

Explanation / Answer

Solution:

The algorithm is given below:

Algorithm:

numberOfPaths(m, n)

//Input: A matrix of size mxn

//output: The number of paths possible from one cell to another cell in the given matrix

for i = 0 to m-1 do

count[i][0] = 1;

for j = 0  to n-1 do

count[0][j] = 1;

for i = 1 to m-1 do

for j = 0 to n-1 do

count[i][j] = count[i-1][j] + count[i][j-1];?

return count[m-1][n-1];

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote