T
My question from C++ Plus Data Structures By Nell Dale, Chip Weems, Tim Richards book,page499 question 16.
please if you have solution manual for this book,help me
We want to count the number of possible paths to move from row 1, column 1 to row N,
column N in a two-dimensional grid. Steps are restricted to
going up or to the right, but not
diagonally. The illustration followsshows three of many paths, if N
= 10.(a) [1] The following function, NumPaths, is supposed to count
the number of paths,
but it has some problems. Debug the function.
int NumPaths(int row, int col, int n)
{
if(row == n)
return 1;
else if(col == n)
return NumPaths + 1;
else
return NumPaths(row + 1, col) * NumPaths(row, col + 1);
}
(b) [1] After you have corrected the function, trace the execution
of NumPaths with n =
4 by hand.
(c) [1.5] You can improve the efficiency of this operation by
keeping intermediate
values of NumPathsin a two-dimensional array of integer values.
This approach
keeps the function from having to recalculate values that it has
already figured out.
Design and code a version of NumPathsthat uses this approach.
(d) [0.5] Show an invocation of the version of NumPaths you
developed in part (c),
including any array initialization necessary.
(e) [1] How do the two versions of NumPaths compare in terms of
time efficiency?
Space efficiency?
copyable code
a)
program code debug the function
public class NumPathsval {
protected int calls1 = 0;
public int numPathsval(int rowval, int colval, int n1)
{
calls1++;
if (rowval == n1)
return 1;
else if (colval == n1)
return 1;
else
return numPathsval(rowval+1, colval, n1) + numPathsval(rowval, colval+1, n1);
}
public static void main(String[] args) {
int n1 = Integer.parseInt(args[0]);
NumPathsval helperval = new NumPathsval();
int count11 = helperval.numPathsval(1,1,n1);
System.out.println(" " + count11 + " paths to (" + n1 + "," + n1 + ")");
System.out.println(" That " + helperval.calls1 + " calls.");
}
}

![public static void main (String[] 큐rag) Integer.parseInt (args NumPathsval helperval new NumPathsval ) int count 11 helperval](http://img.homeworklib.com/questions/f1cd17f0-af8e-11eb-8eb3-b1ee13bc036b.png?x-oss-process=image/resize,w_560)





copyable
code
public class NumPathsval {
protected long calls1 = 0;
protected long[][] pathsFromval;
public long numPathsval(int rowval, int colval, int n1)
{
calls1++;
// Base cases:
if ((rowval == n1) || (colval == n1)) {
return 1;
}
else {
if (pathsFromval == null) {
pathsFromval = new long[n1][n1];
for (int k = 0; k < n1; ++k)
for (int l = 0; l < n1; ++l)
pathsFromval[k][l] = -1;
}
if (pathsFromval[rowval-1][colval-1] == -1) {
pathsFromval[rowval-1][colval-1] =
numPathsval(rowval+1,colval,n1) + numPathsval(rowval,colval+1,n1);
}
// Return
return pathsFromval[rowval-1][colval-1];
}
}
public static void main(String[] args) {
int n1 = Integer.parseInt(args[0]);
NumPathsval helperval = new NumPathsval();
long count1 = helperval.numPathsval(1,1,n1);
System.out.println(" " + count1 + " paths to (" + n1 + "," + n1 + ")");
System.out.println(" That " + helperval.calls1 + " calls.");
}
}


T My question from C++ Plus Data Structures By Nell Dale, Chip Weems, Tim Richards book,page499...
Java 1. Write a getCount method in the IntArrayWorker class that returns the count of the number of times a passed integer value is found in the matrix. There is already a method to test this in IntArrayWorkerTester. Just uncomment the method testGetCount() and the call to it in the main method of IntArrayWorkerTester. 2. Write a getLargest method in the IntArrayWorker class that returns the largest value in the matrix. There is already a method to test this in...
Write a getCount method in the IntArrayWorker class that returns the count of the number of times a passed integer value is found in the matrix. There is already a method to test this in IntArrayWorkerTester. Just uncomment the method testGetCount() and the call to it in the main method of IntArrayWorkerTester. Write a getLargest method in the IntArrayWorker class that returns the largest value in the matrix. There is already a method to test this in IntArrayWorkerTester. Just uncomment...
================Data Structures C++=============== – Implement the Eight Queens Problem This is an object oriented program. This is #1 on page 187 of your book with ONE difference, I’m requiring you add a client program to test your code (a main). If you have the old book the question says “Complete the Queen and Board class for the Eight Queens problem.” On page 179 of your book is a function placeQueens that solves the Eight Queens problem. On page 180 of...
Language is C++ Basic principles and theory of structured programming in C++ by implementing the class: Matrix Use these principles and theory to help build and manipulate instances of the class (objects), call member functions Matrix class implementation from the main function file and, in addition, the Matrix class must have its interface(Matrix.h) in a separate file from its implementation (Matrix.cpp). The code in the following files: matrix.h matrix.cpp matrixDriver.h Please use these file names exactly. Summary Create three files...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct game_piece
{
};
struct game_board
{
};
void game_piece_init_default(struct game_piece* piece)
{
}
void game_piece_init(struct game_piece* piece, char*
new_label)
{
}
char* game_piece_get_label(struct game_piece* piece)
{
return "";
}
char* game_piece_to_string(struct game_piece* piece)
{
return "";
}
void game_board_init(struct game_board* game_board, int rows,
int cols)
{
}
int game_board_is_space_valid(struct game_board* game_board, int
row, int
col)
{
return 0;
}
int game_board_add_piece(struct game_board* game_board, struct
game_piece*
piece, int row, int col)
{
return 0;...
PLEASE COMPLETE IN C++ LANGUAGE
Location row : int = -1 col : int = -1 setLocation(row : int, col : int) getRow(): int getColl): int isEmpty(): bool Details Write all the code necessary to implement the Location class as shown in the UML Class Diagram to the right. Do this in a project named snake (we'll continue adding files to this project as the term progresses). Your class definition and implementation should be in separate files. When complete, you...
Please solve only if you know how to do it. Write the code using
C++ (not Python or Java). Show and explain everything neatly.
COMMENTS (7.5% of programming assignment grade): Your program should have at least ten (10) different detailed comments explaining the different parts of your program. Each individual comment should be, at a minimum, a sentence explaining a particular part of your code. You should make each comment as detailed as necessary to fully explain your code. You...
This is my code for a TicTacToe game. However, I don't know how to write JUnit tests. Please help me with my JUnit Tests. I will post below what I have so far. package cs145TicTacToe; import java.util.Scanner; /** * A multiplayer Tic Tac Toe game */ public class TicTacToe { private char currentPlayer; private char[][] board; private char winner; /** * Default constructor * Initializes the board to be 3 by 3 and...
Below is my code and the instructions for the code. I can't figure out what's wrong. Please help. Tasks This lab has two parts: Writing a searching function for 1D arrays. Writing a simple class. Part 1 – Searching Continuing with arrays, we will now expect you to find information in an array and derive useful properties from the information stored in an array. Start Eclipse. Change the workspace directory location to something "safe". You may want to temporarily choose...
I need a basic program in C to modify my program with
the following instructions:
Create a program in C that will:
Add an option 4 to your menu for "Play Bingo"
-read in a bingo call (e,g, B6, I17, G57, G65)
-checks to see if the bingo call read in is valid (i.e., G65 is
not valid)
-marks all the boards that have the bingo call
-checks to see if there is a winner, for our purposes winning
means...