Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ASAP Using java programming Write a program that generates mazes of arbitrary size using the union-find algorithm. A simple algorithm to generate the maze is

ASAP Using java programming

image text in transcribed

image text in transcribed

Write a program that generates mazes of arbitrary size using the union-find algorithm. A simple algorithm to generate the maze is to start by creating an NxM grid of cells separated by walls on all sides, except for entrance and exit. Then continually choose a wall randomly, and knock it down if the cells are not already connected to each other. If we repeat the process until the starting and ending cells are connected, we have a maze. It is better to continue knocking down the walls until every cell is reachable from every cell as this would generate more false leads in the maze. Test your algorithm by creating a 10 x 10 grid, and print all the walls that have been knocked down. Draw the resulting maze (hand-drawing is acceptable) and include the output of your program (see below). (If you don't include the output of your program, I won't be able to check that your drawing is correct, since your program will use random numbers.) Solutions that do not use the union-find algorithm will receive 0 points. You can use the textbook code or implement union-find yourself, but I recommend using the textbook code. If you implement it yourself, any bugs in your implementation will affect your correctness grade. Suggested strategy: This is one way to approach this problem; you don't have to follow it, as long as you still make use of the union-find algorithm 1. One way to represent a maze is with a 2-dimensional array ("NxM grid" is a strong hint that you want to use a 2D array): int[] [] maze = new int[n][m]; // Assumen and m are already defined o Once you have this variable declared, maze[i][j] represents one square in the grid, assuming 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions

Question

Discuss the advantages and challenges of social media marketing.

Answered: 1 week ago

Question

Explain the three exemptions to the employment-atwill doctrine.

Answered: 1 week ago

Question

a. How will the leader be selected?

Answered: 1 week ago

Question

b. Will new members be welcomed?

Answered: 1 week ago