The RFC for a Java class is set of all methods that can be invoked in response to a message to an object of the class or by some method in ... |
I'm unsure whether the following code would ensure all conditions given in Comparator's Javadoc.
class TotalOrder<T> implements Comparator<T> {
public boolean compare(T o1, T o2) {
...
|
Does anyone know a simple load balance algorithm (formula) that relates users connected, cpu load, network load and memory usage?
This will be used to compare various servers and assign to a ... |
I'm preparing to go to a computer science contest by completing problems from past contests. Most of them are pretty easy, but this one is bugging me...it seems simple but I'm ... |
Let's say you have two instances of the same bean type, and you'd like to display a summary of what has changed between the two instances - for example, you have ... |
What would be the best way to implement a most-recently-used cache of objects?
Here are the requirements and restrictions...
- Objects are stored as key/value Object/Object pairs, so the interface would be a bit ...
|
Is there a Java library for rotating JPEG files (90/180/270 degrees) without quality degraded?
|
|
For my CS class I need to implement Prim's algorithm in Java and I am having problems with the priority queue step. I have experience with priority queues and understand they ... |
This is a long shot, but does anyone know of an algorithm for estimating and categorising text width (for a variable width font) based on its contents?
For example, I'd like to ... |
I created a class with four methods. I inserted print statements into them, so I could see if they work properly. There is no problem with the first three. But when ... |
First of all I have to admit that these are very basic and primitive questions... I want to demonstrate different Algorithms in Java for sorting and searching, and to get a ... |
OK, this is more of a follow-up question: How to compute optimal paths for traveling salesman bitonic tour?
First of all, for the bitonic tour of the traveling salesman problem I ... |
What's the best way to group x amount of items into y amount of groups based on a variable property of each item eg. weight.
Leaving me with y amount of ... |
I am building a software program that follows the scenario:
I have many computers, and add each one of them to the a cluster.
Each computer in the cluster can add a file ... |
Edit: I should rephrase this, what would be a relatively easy algorithm to code in Java for solving a Rubik's cube. Efficiency is also important but a secondary consideration.
Orig: What is ... |
This is where I'm so far:
I have the following the following use case (as impartial jUnit test) to show what I want to achieve:
buffer.add(o1);
assertEquals(1, buffer.size());
buffer.mark();
buffer.add(o2);
assertEquals(2, buffer.size());
buffer.add(o3);
assertEquals(3, buffer.size());
assertSame(o1, buffer.get());
assertSame(o2, buffer.get());
assertSame(o3, buffer.get());
buffer.rewind();
// NOTE: ...
|
I was recently happened to see this animation (http://universe.daylife.com/). I was wondering what are the algorithms behind this applet. How and Where to learn such things?
Thanks
|
I have a data set with attributes like this:
Marital_status = {M,S,W,D}
IsBlind = {Y,N}
IsDisabled = {Y,N}
IsVetaran = {Y,N}
etc. There are about 200 such variables.
I need an algorithm to generate combinations of the ... |
I worked the last 5 days to understand how unification algorithm works in Prolog .
Now ,I want to implement such algorithm in Java ..
I thought maybe best way is to manipulate ... |
import java.util.Scanner;
public class Fraction
{
private int numerator;
private int denominator;
private int product;
private int sum;
public Fraction(int num, int denom)
{
this.numerator=num;
this.denominator=denom;
if (this.denominator == 0){
System.out.println("can ...
|
I am getting an "Illegal start of expression" error in the following code at the location marked by a comment. How can I correct this error?
class planetUfo {
...
|
How can I add business days to the current date in Java?
public Calendar addBusinessDate(Calendar cal, int days) {
//
// code goes over here
//
}
Note:
It should consider weekends too.
|
I am trying to complete the first exercise of USACO.
How can you make the following code more efficient?
It seems that the current problem in the program is that its execution takes ... |
I am writing a program that an HTML scraper that when it grabs the HTML from the page, it returns the HTML, and I want to Grab words that are All ... |
I have implemented the algorithm X using Dancing Links in Java, however, I'm getting unexpected results, that is I'm having dupes of rows of results which are not exact covers.
My code ... |
Heres the code I've made up so far. Its fully functional and the only gripe I have with it is that my output for Weekly and Annual pay is always ... |
I'm writing two classes to handle simple auctions. I have a class ready and working, which handles the operations for a single auction, and now I'm writing another class like an ... |
I am getting stuck with the class work we got this week and its a subject i really want to learn so for once i thought i would do the additional ... |
import java.util.Scanner;
public class GregorianYear
{
private int year;
public GregorianYear(int a)
{
year = a;
}
...
|
We were just assigned a new project in my data structures class -- Generating text with markov chains.
Overview
Given an input text file, we create an initial seed of length n ... |
i have a list 1 column and 100 rows each with a number
the number on each row may not be unique
i need to output the unique list of numbers sorted according ... |
The powerset of {1, 2, 3} is:
{{}, {2}, {3}, {2, 3}, {1, 2}, {1, 3}, {1, 2, 3}, {1}}
Lets say I have a Set in Java...
Set<Integer> mySet = new HashSet<Integer>();
mySet.add(1);
mySet.add(2);
mySet.add(3);
Set<Set<Integer>> powerSet ...
|
I want to compute the cartesian product of an arbitrary number of nonempty sets in Java.
I've wrote that iterative code...
public static <T> List<Set<T>> cartesianProduct(List<Set<T>> list) {
List<Iterator<T>> iterators = new ArrayList<Iterator<T>>(list.size());
...
|
I'd like to run competitions like code golf competitions, but the winner would have the fastest algorithm, not the smallest code.
- One fair way to measure speed of an algorithm is to ...
|
Several tools exists that allow to calculate path coverage for a set of tests, but is there a tool (or an algorithm) that could suggest values to get the best path ... |
How do I use DES in .NET?
Here's how I'd do it in Java:
public static String decrypt(byte[] pin, byte [] desKeyData ) throws Exception ...
|
Looking at this:
MENU_ITEM_BACK#0="Back";
MENU_ITEM_BLOCK_CHANNEL#0="Block";
MENU_ITEM_CLOSE#0="Close";
MENU_ITEM_DETAILS#0="Details";
MENU_ITEM_DIAGNOSE#0="Diagnose";
MENU_ITEM_DOWNLOAD#0="Download";
...and so on (over 500 lines). What would be the best way to automate copying the label name into the label itself. For example,
MENU_ITEM_BACK#0="Back";
would become
MENU_ITEM_BACK#0="MENU_ITEM_BACK";
I am most familiar ... |
I want to write app where user can point any place on map (not only cities) and get timezone in that place.
What data structure (app will not have Internet connectivity) and ... |
My Java program saves its data to a binary file, and (very) occasionally the file becomes corrupt due to a hardware fault. Usually only a few bytes are affected ... |
I am writing a document and was unsure of the following:
- I am going to compare two algorithms that can perform on the same structure but we cant say one will always ...
|
EDIT: I've got it, thanks for all the help everyone! + Cleaned up post a little bit.
Also, this article was very helpful: http://www.codinghorror.com/blog/archives/001204.html?r=1183
Hi all,
I've been asked (as part of ... |
I need to build a small repository of algorithms with implementation and description. I found recently, for example, an efficient permutations generator for permutations of arbitrary length. Where can I find ... |
I have a requirement to calculate the average of a very large set of doubles (10^9 values). The sum of the values exceeds the upper bound of a double, so ... |
I have the start date and the end date. I need to iterate through every day between these 2 dates.
What's the best way to do this?
I can suggest only something like:
Date ...
|
using nQueens problem
how to translate this algorithm to java code
function MIN-CONFLICTS(csp,max_steps) returns a solution or failure
inputs: csp, a constraint satisfaction problem
...
|
I am scratching my head trying to do this and it's eating me up. I know it is not THAT complex. I have a number of items, this number can be ... |
This weekend I spend a few minutes thrashing together an algorithm that would take in a heading (in degrees) and return a String for the cardinal direction (I'm using it in ... |
Here's an algorithm for adding an apostrophe to a given input noun.
How would you contruct a string to show ownership?
/**
* apostrophizes the string properly
* <pre>
* curtis = curtis'
...
|
I know that I can perform divide by 2 using right shift.
For simplicity, take a 4 bit number system
-1 - 1111
-2 - 1110
-3 - 1101
-4 - 1100
-5 - 1011
-6 - ...
|
Taken from Introduction to Algorithms
Describe a ?(n lg n)-time algorithm
that, given a set S of n integers and
another integer x, determines whether
or not ... |
Ok this question is going to be a little abstract.
I have an icon moving along a line which is represented by a series of coordinates stored in a vector, and I ... |
I would like to test the speed of different Java platforms and thought about creating a JojoMips benchmark routine that would work like the Linux BogoMips. It would do a calculation ... |
I used Fortune's Algorithm to find the Voronoi diagram of a set of points.
What I get back is a list of line segments, but I need to know which segments ... |
I am working a much more complex version of this (with vehicle moving in both X and Y directions)
I made this example to get ideas on better ways to accomplish this.
- I ...
|
In a Java program, how can I determine if a dataset I have is following or not a normal distribution?
Is it possible?
Is there an API or an algorithm that I can ... |
How can I measure the speed of code written in Java?
I planning to develop software which will solve Sudoku using all presently available AI and ML algorithms and compare time ... |
What is the most elegant way to do the next stuff:
int i = oneOrZero;
if (i == 0) {
i = 1;
} else {
i = 0;
}
You can ... |
I made an FlowChart diagram editor on Java. It It drows flowscharts and connect them each other and creates me two array. One of it shows connection nodes and lines , ... |
We have configured iReport to generate the following graph:
The real data points are in blue, the trend line is green. The problems include:
- Too many data points for the trend ...
|
I am looking for a way to compute SHA-1 checksums of very large files without having to fully load them into memory at once.
I don't know the details of the ... |
I believe conversion exactly to BigInteger[] would be optimal in my case. Anyone had done or found this written in Java and willing to share?
So imagine I have arbitrary size byte[] ... |
I'm trying to solve this problem, its not a homework question, its just code I'm submitting to uva.onlinejudge.org so I can learn better java trough examples. Here is the problem sample ... |
I am creating a Stratego Game and am having trouble creating an algorithm that can detect when there are no more possible moves because all your pieces are gone or the ... |
I am looking for an algorithm analysis tool for java that can calculate Big 0 of a function. Ideal I would like to make it part of my build process, along ... |
I have a set of X items such as {blower, mower, stove} and each item has a certain percentage of times it should be selected from the overall set {blower=25%,mower=25%,stove=75%} along ... |
I am trying an encryption-decryption code in java. When I am trying to run it with JDK and code in class with main method it is running fine. But when I ... |
I'm trying to write the Diamond-Square algorithm in Java to generate a random map but can't figure out the implementation...
Anyone with some Java code (or other language) so i ... |
i want to implement SHA 1 Algorithm using java.
Can any one help me
Thanks in advance
|
Suppose I have the array
int a[] = new int[] { 0xBCDA, 0xABFE, 0xBCAD, 0xEFCA, 0xFFCA }
I know that there is always some hexadecimal number which occurs in all number or in ... |
I'm looking for some way of using the number-crunching ability of a GPU (with Java perhaps?) in addition to using the multiple cores that the target machine has. I will be ... |
http://en.wikipedia.org/wiki/All_nearest_smaller_values. This is the site of the problem
and here is my code, but I have some trouble to implement it:
import java.util.*;
public class stack{
public static void ...
|
Suppose code is given like this:
pattern_mask[pattern[i]] &= ~(1UL << i);
What kind of type is this in Java? How do I implement this in Java?
|
Look at the following line of java:
Mac.getInstance("HmacSHA1");
If I put this in a simple test program, it runs without problems on my server. However, if I use this line in a container, ... |
I would like to implement a simple substitution cypher to mask private ids in URLs
I know how my IDs will look like (combination of upperchase ascii, digits and underscore), and they ... |
As a School assignment i'm required to implement Naïve Bayes algorithm which i am intending to do in Java.
In trying to understand how its done, i've read the book "Data Mining ... |
i know that horners method for polynomial pultiplication is faster but here i dont know what is happening here is code
public class horner{
public static final ...
|
I have following code:
public class LCS1 {
public static String lcs(String a,String b) {
String x;
String y;
...
|
i have question how write program which calculates following procedures
http://en.wikipedia.org/wiki/Tetration
i have exponential program which returns x^n here is code
public class Exp{
public static long ...
|
I've been working on the problem of calculating the modular inverse of an large integer i.e. a^-1 mod n. and have been using BigInteger's built in function modInverse to check ... |
Is there utility program for Page replacement algorithm simulation in Java?
|
On the slides I am revising from it says the following:
Live objects can be identified either by maintaining a count of the number of references to each object, or ... |
In the book "Introduction to Algorithms", second edition, there is the following problem:
Suppose we have some array:
int a[] = {1,2,3,4}
and some random priorities array:
P = {36,3,97,19}
and the goal is to permute ... |
here is code of bigrand function in c code
int bigrand (){
return RAND_MAX* rand()+rand();
}
please tell me what is equivalent code in java?
|
i know java API function charAt for example
String s="dato"
char r=s.charAt(0); r is equal d
but my question is how realy it works or what function ... |
I am trying to solve a combinatorics problem, it seems easy, but i am having some trouble with it.
If i have at most X tables, and N persons to sit on ... |
The Algorithm traverses a 2D NxN array, making every element the average of its 4 surrounding neighbors (left, right, top, down).
The NxN array has initially all zeros and is surrounded by ... |
I have a task to create a crossword, a specific one. All the answers are given, but their places are unknown. Program must read a file with board scheme like this ... |
I'm trying to make a decent Java program that generates the primes from 1 to N (mainly for Project Euler problems).
At the moment, my algorithm is as follows:
Initialise an array of ... |
Say you have an API that is not accessible to change:
List<LegacyObject> getImportantThingFromDatabase(Criteria c);
Imaging Legacy Object has a ton of fields and you want to extend it to make getting at certain ... |
Im need to implement a Roulette Prediction System (Roulette Calculator).
The scenario is:
The player put on the system the values from roulette, and the system tip to him the best bet and ... |
I'm developing a software to generate a Turing Machine from a regular expression.
[ EDIT: To clarify, the OP wants to take a regular expression as input, and programmatically generate a ... |
here is problem about sum of factorial of digit
http://projecteuler.net/index.php?section=problems&id=254
also
here is Define sf(n) as the sum of the digits of f(n). So sf(342) = 3 + 2 = ... |
This is the code for encrypting and decrypting a string in java using AES algorithm.
StackTrace:
javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher
...
|
I am new to Java and referring Head-First book.
Do I have to learn Algorithms to be able to make programs in Java?
Should I learn Algorithms first or only Java books ... |
How can I implement Near array based Prim's algorithm and Disjoint Set based
Kruskal's algorithm in java. I have tried but failed. So I can asking for some hints/helps
|
In these days I'm coding some data structures in Java. Many of them (if not all) offer a very simple interface (add, contains, delete) but under the hood there are non-trivial ... |
I was given an English vocabulary assignment by my teacher.
Choose a random alphabet, say 'a'
Write a word from the alphabet, say
'apple' Take the last word ... |
I have a gray scale image of 64x64. I found the dots of the contour by a simple algorithm:
- find brightest spot (Example: 100)
- divide by 2 (100/2 = 50)
- define a band ...
|
Is there an open source Java library/algorithm for finding if a particular piece of text is a question or not?
I am working on a question answering system that needs to analyze ... |
I was asked this in an interview. Not counting the time it takes to execute the method body.
Any ideas?
|