Question: C++ Write a program to 4-color a map using recursion and backtracking. Typing make coloring should create an executable coloring which solves the following problem.

C++ C++ Write a program to 4-color a map using recursion and backtracking.

Typing make coloring should create an executable coloring which solves the following

Write a program to 4-color a map using recursion and backtracking. Typing make coloring should create an executable coloring which solves the following problem. The input file (whose name will be passed at the command line) will have three parameters on the first line: how many "countries" there are in the map, the number of rows in the map, and the number of columns in the map. This time, the map will never be bigger than 80 by 80 characters, and will contain at most 15 countries. The countries are denoted by characters ','B', up to the letter for the highest country number: for this problem, each country gets its own designated letter (two disjoint countries will never share a letter). Here is an example of what the input might look like: 5 6 13 BBBBBACDEEEDD Each country will always be contiguous; in other words, you can always walk from any point in a country to any other just going horizontally or vertically. We will say that two countries share a border if at least one square of one country is horizontally or vertically adjacent to at least one square of the other. In the example above, A shares a border with B and C, and D shares a border with B and C and E, and C and E also share a border. A and D do not share a border, and neither do B and C, because they only touch diagonally. Write a program to 4-color a map using recursion and backtracking. Typing make coloring should create an executable coloring which solves the following problem. The input file (whose name will be passed at the command line) will have three parameters on the first line: how many "countries" there are in the map, the number of rows in the map, and the number of columns in the map. This time, the map will never be bigger than 80 by 80 characters, and will contain at most 15 countries. The countries are denoted by characters ','B', up to the letter for the highest country number: for this problem, each country gets its own designated letter (two disjoint countries will never share a letter). Here is an example of what the input might look like: 5 6 13 BBBBBACDEEEDD Each country will always be contiguous; in other words, you can always walk from any point in a country to any other just going horizontally or vertically. We will say that two countries share a border if at least one square of one country is horizontally or vertically adjacent to at least one square of the other. In the example above, A shares a border with B and C, and D shares a border with B and C and E, and C and E also share a border. A and D do not share a border, and neither do B and C, because they only touch diagonally

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!