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

I need to write a program in C that uses Prim\'s algorithm and generates a rando

ID: 3674195 • Letter: I

Question

I need to write a program in C that uses Prim's algorithm and generates a random maze (a random number generator would give weights to the branches of each node to generate a different maze everytime), that will always be a pefect square (input by the user: e.g 4x4 [user would input 4], 5x5 [user input would be 5], 6x6 [user input would be 6]... etc.). The start of the maze would always be the top left corner, and the end of the maze would always be bottom right. All the program needs to do is output the maze to the terminal using asterisks (*) as the maze walls. Any help coding this in C would be really helpful.

Explanation / Answer

import java.util.*; public class Prim { public static void main(String[]args) { // These are the dimensions of generated maze int rows=20, columns=20; // This is to build maze and initialize with only walls StringBuilder s = new StringBuilder(columns); for(int x=0;x