Max Brown

Greenhorn
+ Follow
since Oct 24, 2018
Max likes ...
C++ Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Max Brown

This is where the error is


it only shows up for 100000 elements. works otherwise
4 years ago
So I moved out the clock time calculation and analysis to the main method. So far, its been working for everything but when I bring up the 100000 element arrays, I get errors
Main Method


quicksort regular



partition


Error:


So where would I place the array access checks?
4 years ago
Hi,

I'm currently doing a sorting project where we have to implement random arrays for 10, 100, 1000, 10000, and 100000 elements per sorting algorithm. I've created a method to generate the arrays and I've done some of the sorting methods in order to calculate clock times, array access times, and comparison times. I'm running into a problem with a few of my algorithms. For the one method algorithms like bubble sort and selection sort, I was fine. But when I got into merge sort and quick sort, I see some issues popping up. Can someone please take a look at what I've done wrong?

Generate array


Analysis


mergesort


quicksort with insertion sort


The issue popped up with QuickSort alone as well.
This is how I'm calling it in the main method


Thank you for your help!
4 years ago
Hi,

I'm doing an assignment for class where we're given the following code in order to solve the 8-piece sliding puzzle problem. We are to complete the method boolean isSolvable(Configuration configuration). I've been able to set up the bfs algorithm but I'm having trouble getting the method to actually figure out if the configuration is solvable. Right now I'm getting false, false, false when the output should be true true false. Can someone see where I'm going wrong?

Here is the given code:


This is the suggestion from my professor:

This is my attempt:


My Output: false, false, false
4 years ago
Thanks for replying!

I see what you mean by smelly code. First of all, all my methods are static. I was under the impression that because they're running in the static main method, they'd have to be static as well. I'll look into static methods more. Then, I have a lot of display messages and some duplicate. I'm not quite sure what you mean by leaky abstractions though.
I feel like it should be shorter but I'm not sure how to go about doing so. Right now my logic is to check the rows, columns, then both diagonals.
5 years ago
Hi,

I'm completing an assignment for class to create a 2 player tic-tac-toe game using 2D arrays. I've written a lot of the code and I'm wondering if there's any way to improve my won method. Also, I'm not sure how to start up the game in the main method. Normally, I'd have multiple classes and create an instance of the game in a final driver class but for this lab, everything had to be in one class. Right now it's just looping the output of "We have a winner. Player 2 wins" without letting me input anything.

5 years ago