Consider a network of streets laid out in a rectangular grid, In a northeast path from one point in the grid to another, one may walk only to the north (up) and to the east (right). Write a program that must use a recursive function to count the number of northeast paths from one point to another in a rectangular grid. Your program should prompt the user to input the numbers of points to the north and to east respectively, and then output the total number of paths. Notes: 1. Here is a file (timer.h  download and timer.cpp download) which should be included in your program to measure time in Window or Unix (includes Mac OS and Linux) systems (use start() for the beginning of the algorithm, stop() for the ending, and show() for printing). 2. The computing times of this algorithm is very high, and the number of paths may be overflow, don't try input numbers even over 16. 3.  Name your recursive function prototype as calcPath(int north,  int east) to ease grading.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Consider a network of streets laid out in a rectangular grid,

In a northeast path from one point in the grid to another, one may walk only to the north (up) and to the east (right).

Write a program that must use a recursive function to count the number of northeast paths from one point to another in a rectangular grid. Your program should prompt the user to input the numbers of points to the north and to east respectively, and then output the total number of paths.

Notes:

1. Here is a file (timer.h  download and timer.cpp download) which should be included in your program to measure time in Window or Unix (includes Mac OS and Linux) systems (use start() for the beginning of the algorithm, stop() for the ending, and show() for printing).

2. The computing times of this algorithm is very high, and the number of paths may be overflow, don't try input numbers even over 16.

3.  Name your recursive function prototype as calcPath(int north,  int east) to ease grading.

4. Paste your output 

/ timerh for CMPSCc122 lab 8 (on Window or Uinx system)
//Measure time in Window
/Define a Timer object t, use tstart() for beginning of the algorithm, tstop) for the ending, and tshow) for printing
/ 6/13/2020 Remove Unix code and saperate the header file file timerh to contains only function prototypes
#include <ctime>
#include <string
#include <iostream>
#include "timerh"
Timer:Timer )
label = Process Timer";
reset);
Timer:Timer (const std:string &label)
{
Timer:label = label;
reset():
Timer:-Timer)
void
Timer: :reset(void)
{
tps = CLOCKS_PER_SEC;
end_time = 0;
usertime = 0;
systemtime = 0;
elapsedtime = 0;
waittime = 0;
void
Timer:start(void)
{
start_time = clock):
void
Timer:show(void)
std::cout
« label << "n"
くく
«* Elapsed Time
<elapsedtime
«'s«std:endl;
}
double
Timer:lapsed(void)
returm elapsedtime;
void
Timer:stop(void)
{
end_time = clock0:
elapsedtime = ((doubleXend_time -
start_time )(double)tps );
if(elapsedtime < 0.001)
{
elapsedtime = 0.001;
if( waittime <0.00)
{
waittime = 0.00;
Transcribed Image Text:/ timerh for CMPSCc122 lab 8 (on Window or Uinx system) //Measure time in Window /Define a Timer object t, use tstart() for beginning of the algorithm, tstop) for the ending, and tshow) for printing / 6/13/2020 Remove Unix code and saperate the header file file timerh to contains only function prototypes #include <ctime> #include <string #include <iostream> #include "timerh" Timer:Timer ) label = Process Timer"; reset); Timer:Timer (const std:string &label) { Timer:label = label; reset(): Timer:-Timer) void Timer: :reset(void) { tps = CLOCKS_PER_SEC; end_time = 0; usertime = 0; systemtime = 0; elapsedtime = 0; waittime = 0; void Timer:start(void) { start_time = clock): void Timer:show(void) std::cout « label << "n" くく «* Elapsed Time <elapsedtime «'s«std:endl; } double Timer:lapsed(void) returm elapsedtime; void Timer:stop(void) { end_time = clock0: elapsedtime = ((doubleXend_time - start_time )(double)tps ); if(elapsedtime < 0.001) { elapsedtime = 0.001; if( waittime <0.00) { waittime = 0.00;
E// timer.h for CMPSC122 lab 8 (on Window or Uinx system)
// Measure time in Window
// Define a Timer object t, use t.start() for beginning of the algorithm, t.stop() for the ending, and t.show() for printing.
// 6/13/2020 Remove Unix code and saperate the header file file timer.h to contains only function prototypes
1
2
6
E#ifndef TIMER_H
#define TIMER_H
7
E#include cctime>
#include <stringx
#include <iostream>
10
11
12
13
14
Eclass Timer
15
{
public:
16
17
//
18
Timer();
19
20
//
21
Timer(const std::string &label);
22
// -----
-Timer();
23
24
25
26
//
27
void start(void);
28
29
//
30
void stop(void);
31
// -----
void show(void);
32
33
34
35
double lapsed(void);
36
37
private:|
38
39
//
40
void reset(void);
41
42
std::string
43
label;
44
45
long
46
tps;
47
clock_t
start_time,
end_time;
48
49
50
51
52
53
double
54
usertime,
systemtime,
elapsedtime,
waittime;
55
56
57
58
};
59
tendif
60
// eof timer.h
Transcribed Image Text:E// timer.h for CMPSC122 lab 8 (on Window or Uinx system) // Measure time in Window // Define a Timer object t, use t.start() for beginning of the algorithm, t.stop() for the ending, and t.show() for printing. // 6/13/2020 Remove Unix code and saperate the header file file timer.h to contains only function prototypes 1 2 6 E#ifndef TIMER_H #define TIMER_H 7 E#include cctime> #include <stringx #include <iostream> 10 11 12 13 14 Eclass Timer 15 { public: 16 17 // 18 Timer(); 19 20 // 21 Timer(const std::string &label); 22 // ----- -Timer(); 23 24 25 26 // 27 void start(void); 28 29 // 30 void stop(void); 31 // ----- void show(void); 32 33 34 35 double lapsed(void); 36 37 private:| 38 39 // 40 void reset(void); 41 42 std::string 43 label; 44 45 long 46 tps; 47 clock_t start_time, end_time; 48 49 50 51 52 53 double 54 usertime, systemtime, elapsedtime, waittime; 55 56 57 58 }; 59 tendif 60 // eof timer.h
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education