What is the graph being searched in your solution?

Published by Jeannie R. Ferrell

Dec 8, 2022

s

Struggling with a similar assignment? Don’t know where to start? Don’t have time to work on this? Get a high-quality paper written for you from scratch – PLAGIARISM FREE, guaranteed to get you a good grade. To get started, please click on the Submit Your Instructions at the bottom of the page.

Execute this
CSC301 – Data Structures 2 consists of two separate deliverables. The first is a puzzle application (a game) while the second is a solver for the puzzle. The puzzle itself is described in its own section below. Allowed changes to classes You may add additional methods to the classes you were given and you may also add other classes (that you make) in their own separate files. Just make sure to include all additional files when you make you submission so that I can run your code. You may also make classes implement Comparable if you want. • Allowed imports You may import and use Java’s Random class as well as Java’s versions of symbol tables (Java’s various Map and Set classes.) The Game/Puzzle The game/puzzle consists of a grid of 2 rows of 5 cells each. Each cell contains a number between 0 and 9 inclusive. The object of the game/puzzle is to arrange all the numbers in the cells in order. The top row should have the numbers 0-4 in order left to right and the bottom row should have the numbers 5-9 in order left to right. You move the numbers around by making one of the following nine possible moves:
• 1: Shift the numbers in the top row to the right one position (the right-most number “wraps around” to the left-most position.
• -1: Shift the numbers in the top row to the left one position (the left-most number “wraps around” to the right-most position.
• 2: Shift the numbers in the top bottom to the right one position (the right-most number “wraps around” to the left-most position.
• -2: Shift the numbers in the bottom row to the left one position (the left-most number “wraps around” to the right-most position.
• 3-7: Swap the positions of the 2 numbers in the given column. The columns are numbered 3 through 7 from left to right. The player continues to make moves by indicating the move number (-2, -1, 1, 2, 3, 4, 5, 6, or 7) until either they win by arranging the numbers so that they appear in the cells in order, or they lose by repeating a board position. This is probably easier to understand via a demonstration. A demonstration of how the game is played will be given in class, so please make sure to take a look at the lecture recording if you did not attend the class meeting where the demonstration was given.
Deliverable #2 The second deliverable has two related components • You must implement the Solver class. you are allowed to define other classes to help you (as well as use “built-in” Java classes). For example, the Board class from part 1 of the project can be especially useful, after a few additions/changes. The point of the solver class is the solve method which takes a 2-by-5 array of bytes containing the numbers 0-9 that represent the initial state of the puzzle board (in the same way that a 2-by-5 array can be passed to the Board(byte[][] b) constructor from deliverable #1) and which returns an array of ints representing a sequence of moves that can be made to solve the puzzle. For the solution to be considered correct, not only must the sequence of moves when made in the order they appear in the array lead to the solved puzzle state (the numbers appearing in sorted order in the puzzle), but there must not be a solution that uses fewer moves. If given a completely clear board as input, the solution requires no moves and an array of size 0 must be returned. The class also has a no argument constructor that will be called to construct/initialize the solver object. It’s up to you what this constructor does. (There are valid solutions to the project where the constructor does absolutely nothing, but there are also solutions where some preprocessing work done in the constructor allows the solve method to be much faster.)
Please answer each of the questions below.. Make sure you provide a concise answer, and like the homework videos, PLEASE AVOID explaining your code line by line. Instead, make sure you explain the idea.
WHY did you choose to do what you do?
If your answer to one of the questions includes the use of a data structure we discussed in class, explain which one, and why/how you are using it. Please Avoid explain what the data structure itself does or how it works. For example, if you use a BinarySearchST, do not explain to me how binary search works, how insertion works, etc. Instead, explain, what are the keys, what are the values, and why/how you using the symbol table in your solution. Breadth-first search is done on a graph.
What is the graph being searched in your solution?
What are the vertices of the graph and when is there edge between two vertices?
During breadth first search, you need to loop over all neighbors of a given vertex. Show me where and how your code does this. How does your code know who the neighbors of a given vertex are?
Breadth-first search requires that you mark vertices as you encounter them to keep track of the vertices you have already seen. The book’s code uses an array to do this. How did you keep track of marked vertices?
Don’t forget to show me the part of the code that does this. To be able to recover the solution path, breadth-first search requires that for each vertex, you keep track of what vertex you came from when you first encountered it (edgeTo array). How do you keep track of that in your solution?
Don’t forget to show me the part of the code that does this. Assuming your breadth-first search has already been performed, how is the solution itself recovered?
Again, avoiding explaining line by line. Instead, explain what has been stored in the various fields/variables by the BFS, and how that information is used to construct a solution. Make sure that you show me the code that constructs/extracts the solution from the stored information. (Note that there could be some overlap between this question and previous question.) If your solution does only a single breadth-first search at the beginning, regardless of the number of times solve is called, how did you do it?
be based on how fast your code runs on my computer. For reference, when I use my first solution where I was trying to be efficient the Timing test finishes in 8 seconds. I then coded up another solution where I tried to duplicate exactly the book’s BFS algorithm, and that one took 75 seconds. Using these solutions as a baseline, I will award a minimum of 2 out of 4 points for any solution that takes a total of 75 seconds or less and all 4 points for any solution that takes a total of 10 seconds or less on my computer. Of course, the running time on your own computer will likely be different, but probably not by too much. • There are 6 video questions worth 5 points each for a maximum possible score of 30 points. Note that your score on the video questions will be based both on how well you explain what you did and on how well you solved the problem. Inefficient solutions will lose points. Also, you can’t get credit for the last video question (about performing just one BFS regardless of how many times solve is called), unless your code actually works that way. Tips when my tests fail: The name of each test includes an indication of how many moves the solutions will require. The body of each test includes calls of the form: stringToByteArray(″1634052789″); This call creates the starting position for the puzzle. The digits in the string appear in the same order that they will appear in the puzzle board. The first five are the five numbers in the top row and the second five are the five in the bottom row. You can use this to create your own test (or main) that you can debug independent of the Junit tests. For example, you could write a main that creates a 2D byte array with the numbers in the order they appear in the String and then calls your solve method with that array. Example: Below and to the left is a figure representing the puzzle we want to solve. Below and to the right is a Java program that would call your Solver.solve method to solve the puzzle and print out the answer. 1 6 3 4 0 5 2 7 8 9 The solution with the fewest number of moves is to swap the 6 and the 2 (4 move), and then shift the top row to the right (1 move). So the print statement at the end of main should display [4, 1] For this particular example, any other output would be wrong and would result in the test failing. Of course, the Junit tests do not print solutions. They only verify that the solutions your code produces are correct.
Important Info

The order was placed through a short procedure (customer skipped some order details).
Please clarify some paper details before starting to work on the order.

Type of paper and subject
Number of sources and formatting style
Type of service (writing, rewriting, etc)

n

Need Writing Help? Our writing specialists are here 24/7, every day of the year, ready to support you! Instantly chat with an online tutor below or click here to submit your paper instructions to the writing team.

[jetpack-related-posts]

More than just an assignment.

GET THE GRADES YOU DESERVE | A OR A- GUARANTEED
NO MORE SLEEPLESS NIGHTS DOING RESEARCH
NO MORE LATE POINTS DEDUCTIONS 
GET A QUALITY PAPER SENT TO YOUR EMAIL
GET GOOD GRADES ON YOUR ASSIGNMENTS
Explore Now →

Who is this homework service for?

* If you are having a really hard class and want to get through it, then this is for you.

* If you have a medical emergency or someone close to you has a medical emergency and you don’t think you’ll be able to turn your assignment on time, this is definitely a service you could use.

* You can use us if you are having a tough Professor who won’t give you the grades you deserve.

* If you have a tight work schedule and you are getting points deducted for not submitting assignments on time.

* English might not be your first language and you feel like you are being left behind in class because of it.

* If you have a large project coming up and don’t think you have enough time to get it done well, definitely reach out to us.

TALK TO SUPPORT
{

Super stoked you are checking us out! We would like to help you with your assignment. We just need a few things from you:

* The full assignment instructions as they appear on your school account.

* If a Rubric is present, make sure to attach it.

* Any relevant weekly readings or learning resources.

* Include any special announcements or emails you might have gotten from your Professor regarding your assignment.

* Any templates or additional files required to complete the assignment.

If your assignment is somewhat complex and you need to explain it, please don’t hesitate to reach out to me via live chat. 

 

FAQ

Frequently asked questions

How soon can I get my paper done?

It depends with your deadline. If you need your paper completed in 3 hours, we will deliver it in that time. All you need to do is indicate your deadline in our custom order page here. Alternatively, if you are sending us your instructions via email, please be sure to indicate your deadline.

Will it be completely original? I don't want to be caught in a case of Academic Integrity Violation.

We are as paranoid as you are. Maybe even more! And we understand that the greatest sin you can commit in your academic journey is plagiarizing your academic work. To that end, we have made sure that we check and double-check our papers using high quality plagiarism detection tools such as SafeAssign and Turnitin before submitting the paper to you.

Who is my writer? Is he/she a native English Speaker?

All our writers are native English Speakers. That is not to say that ESL writers are not good, we just prefer hiring native writers because we want the very best people working on your paper. This might mean paying a little bit more for your paper as opposed to when you pay a foreign company whose writers are non-native English Speakers.

What if I need revisions? Will your charge additional for this?

Of course not! If you do happen to require a revision on your paper, our team will handle it for you free of charge. Matter of fact, we won’t rest till you are happy with your paper. So, ask for as many revisions as you need, it’s completely FREE!

Will you give me my money back if I don't like my paper?

We have very few instances where we delivered a paper that a client didn’t fall in love with. But if it so happens that you don’t like your paper for any reason whatsoever, we’ll refund your money back no questions asked.

I have more assignments after this, can you help me with those too?

Of course! And what’s even better is that we can reserve a writer permanently to work on your entire class. This comes in handy for projects which build up on each other and where you need just one writer, one writing style.

I got my order information wrong, can I change that?

Yes you can. Just reach out to our support team via email (support@essaynook.com) or live chat here and they’ll help you change the instructions.

Can I place an order via email instead of going through the order page?

Yes you can. Email Anna at anna@essaynook.com, she’s in charge of our sales team. Alternatively, you can talk to our Live Chat team here and request to speak to Anna.

Trusted by Thousands of Students

Delivering quality assignments since 2007