All Questions
19 questions
2
votes
1
answer
109
views
Optimizing minHeap implementation
I have implemented a java class for minHeap but it is not working as fast as I want . I want some help to change it to work faster in insertion or deleting the minimum node.
Here is my implementation:...
4
votes
1
answer
199
views
Parsing weather station XML on raspberry pi
This if for a school project that is all about getting the most performance possible out of a relatively weak computer.
For this project we have received a weather station report generator that ...
1
vote
2
answers
290
views
Optimize printing massive strings to System.out with respect to time
I need to cut the time it takes to print a large string by ~50%.
I went from using s1 + s2 to using StringBuilder, and instead ...
0
votes
2
answers
2k
views
Data structure to count occurrences of words
I have some code for a assignment where the main marks are awarded based on efficiency. The program uses a given wordgenerator which generates random words and adds them to a user-made data structure. ...
2
votes
2
answers
178
views
My spaceship is slow to explode after being hit by the asteroid
I am making a game for my computer science class. My professor's requirements are:
Write a Processing program that draws a triangle in the middle of the window.
Rotate the triangle when the left and ...
13
votes
5
answers
4k
views
Enter my Matrix
Here is my next Java assignment: create a Matrix class that can add and multiply two matrices together. I was given some code as a skeleton and then fleshed it out ...
6
votes
3
answers
2k
views
Optimizing this Knight's Tour
My assignment in CS was to make a knight's tour application that could solve the problem from any starting position. I had just finished the code so excuse the lack of deeply descriptive comments. My ...
8
votes
2
answers
3k
views
Finding the longest Collatz sequence cycle
I wrote a program to calculate Collatz sequences for initial numbers between 1 and a given integer i, then find the one with the largest cycle length. My code is ...
3
votes
1
answer
233
views
Hangman game background image possibly inefficient
I'm making a Hangman game and it seems that my code doesn't provide me much freedom with using layouts. I added an image to my JFrame then I added a ...
0
votes
1
answer
121
views
Processing a string from the console
How can I make this program run faster? On enter, I have a string from the console. For example:
1 1 7 3 2 0 0 4 5 5 6 2 1
On exit, it will be
...
2
votes
2
answers
1k
views
In-order Predecessor BST review
I was referred here from StackOverflow, so here is what I posted over there:
So, for an assignment, I have to construct a binary search tree, plus an assortment of related functions. I have them all ...
5
votes
1
answer
4k
views
How is my quarterly sales statistics program?
Am I making good use of a 2-D array? Is this code inefficient? I am supposed to receive input from 6 departments for 4 quarterly periods in Java.
My assignment asks:
Quarterly Sales Statistics
...
3
votes
3
answers
4k
views
Approximating sines and cosines using up to five terms of the Taylor series
I have one programming question:
The sine and cosine of \$x\$ can be computed as follows:
\$\sin(x) = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \frac{x^9}{9!} - \dots\$
...
4
votes
2
answers
2k
views
Searching through a contact list for given criteria
I have been staring at this code for awhile now and I am thinking there is a way to optimize it (namely the if-else statement ...
1
vote
3
answers
279
views
Primes Tester for speed performance
I was given a homework assignment in Java to create classes that find Prime number and etc (you will see in code better).
...