algorithm 3 « algorithm « Java Collection Q&A

Java Collection Q&A
3.Array Byte
4.Array Char
5.Array Convert
6.Array Dimension
7.Array Integer
8.Array Object
9.Array String
14.Garbage Collection
Java Collection Q&A » algorithm » algorithm 3 

1. Java Algorithm Question

Problem Statement :: In Java ,Given an array of ints, is it possible to choose a group of some of the ints, such that the group sums to the given target, ...

2. Levenshtein to Damerau-Levenshtein

I'm sitting here and programmnging some algorithms for my main program in Java (well the first one so far). I programmed the levenshtein algorithm just fine thanks to wiki being so ...

3. Java grouping algorithm

Given an array of ints, is it possible to choose a group of some of the ints, such that the group sums to the given target, with this additional constraint: if ...

4. How to generate MFCC Algorithm's triangular windows and how to use them?

I am implementing MFCC algorithm in Java. There is a sample code here: at Matlab. However I have some problems with mel filter banking process. How to generate ...

5. java help need big help

In the following code we can add 6 times. I want to to reduce it to three times.

package dsa;

import javax.swing.JOptionPane;

 * @author asda
public class myQueue

6. Library of optimzation algorithms in java

I'm looking for some library(open source will be perfect) that have realization of different optimizaion algorithms in java. Actually I need a dual simplex method. It will be good if it ...

7. Forward chaining and Backward chaining in java

What will be the best approach to implement forward chaining and backward chaining for reasoning process in java? We have been given Horn-form knowledge base which has set of statements. I have tried ...

8. Will this algorithm generate a cryptographically-secure bitstream?

I'm in the rough stages of creating a Spades game and I'm having a hard time thinking up a cryptographically-secure way to shuffle the cards. So far, I have this:

  • Grab 32-bit ...

9. Stuck implementing Wikipedia's A* ("A star") algorithm

I'm implementing the A* search algorithm from this pseudo on wikipedia's article:

function A*(start,goal)
     closedset := the empty set    // The set of nodes ...

10. Generate a infinite line with the help of markov chain theory

So let me explain my problem a little better now (please reopen this question). I heard of markov chain theory when thinking about a method to generate procedural lines to build ...

11. Java code to implement hitting set algorithm

Suppose F is a collection of sets. An edge-labeled and nodelabeled tree T is an HS-tree for F iff it is a smallest tree with the following properties: (1) Its root is ...

12. What are the differences between MFCC and BFCC?

I have implemented MFCC algorithm and want to implement BFCC. What are the differences between them and is it enough just to use another function instead of frequency to mel (2595 ...

13. How to decrease the size of SHA1?

I have a problem, maybe a silly question, I want to store data in a database after I hash with the SHA1 algorithm. However, at a future time, the size in ...

14. Reducing the granularity of a data set

I have an in-memory cache which stores a set of information by a certain level of aggregation - in the Students example below let's say I store it by Year, Subject, ...

15. What is incorrect with my Voronoi generator?

import java.awt.Color;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Random;

import javax.imageio.ImageIO;

public class Voronoi
    public static void main(String args[])
        Random ...

16. Algorithm for Parsing an XML

I was reading one of the interview question about parsing an XML: I wrote a very high level and incomplete skeleton of the algorithm , and was looking for some ...

17. How can I make this backtracking stop without using System.exit(0)?

static void LasVegas(int []tablero, int f, int ultimaReina){

    HashSet<Integer> enterosUsados = new HashSet<Integer>();

    if (ultimaReina!=-1) enterosUsados.add(ultimaReina);
    if ((ultimaReina-1) >=0){enterosUsados.add(ultimaReina-1);}

18. Routing algorithm for pipelines

I have to create an algorithm for routing purposes in pipeline industry. Like we have 4 pipelines available and in between there can be either injection of oil or it can ...

19. What is the algorithm OR mathematics for Fisher's Exact Test?

I need a Fisher's Exact Test for a matrix n x m. I've been searching for hours and I've only found one example code, but it's written in Fortran. I've been ...

20. HmacSHA1 generates different signatures on different systems using same secret

I have a jersey oauth provider that uses HmacSHA1 for signing/verifying requests. This works for my development & test platforms where client & server are both different physical systems. However, when ...

21. Pattern-Matching Algorithm

This is slide from class at my University, it about Pattern-Matching Algotithm.. enter image description here And I try to code it in Java below;


22. Runtime error in UVA Online Judge

I'm doing problem 10003 "cutting sticks" of the UVa online judge, I'm pretty sure my code works and I think I' correctly exiting the problem. But still I get a runtime ...

23. Need an algorithm for square root that provides a "remainder"

I'm writing a calculator without using decimals (supports only Rational numbers), but I'd like to be able to do a version of square root. When a square root function is ...

24. Java code to find the area of a circle which is inside a rectangle

I'm writing a .NET program for an engineering company. Their specification is to find the number of holes (either of same or different radius) on a rectangular plate and then to ...

25. The efficeient approach to calculate the interaction or union of two sets

I have two arraylists, where each of which stores a set of elements. I would like to obtain and output the intersection of these two sets. Is there any efficient and ...

26. Java implementation of Long.numberOfTrailingZeros()

Link to documentation: Here is the Java implementation source code:

 * Returns the number of zero bits following the lowest-order ("rightmost")
 * one-bit in the two's complement binary representation ...

27. how to actually get the nearest neighbor in weka using java

so I've been trying to use the Ibk nearest neighbor algorithm that goes together with the weka machine learning library..... I know how to classify instances, but I want to implement the ...

28. how to check if curves are similar

How to compare two black curves on a white background? How to do it as fast? For example this and this enter image description here are similar, but this enter ...</p></div></td></tr><tr><td><div class='articleProductElement'><h3 class='articleProductElementTitle'>29. <a href=''>Min/Max Tic Tac Toe</a><span class='articleProductElementHost'></span></h3><p class='articleProductElementParagraph'>I am creating a tic tac toe with min/max so I can expand it to alpha-beta pruning. So during my min/max I find if a path with lead to +1 (X ...</p></div></td></tr><tr><td><div class='articleProductElement'><h3 class='articleProductElementTitle'>30. <a href=''>Java bulb switch problem</a><span class='articleProductElementHost'></span></h3><p class='articleProductElementParagraph'>I have an array list containing 5 bulbs. I can iterate throuh them like this

<pre><code>for(Bulb bul : list){

No a bulb is switched off/on. The effect is that ...</p></div></td></tr><tr><td><div class='articleProductElement'><h3 class='articleProductElementTitle'>31. <a href=''>best way to choose the majority among three</a><span class='articleProductElementHost'></span></h3><p class='articleProductElementParagraph'>Edit: for what could be understood from explanations, answers and example:

I have three variables, each variable can assume just two specifics values. For example, this value can be 0 or 1.

I'd ...</p></div></td></tr><tr><td><div class='articleProductElement'><h3 class='articleProductElementTitle'>32. <a href=''>Finding local Minimum</a><span class='articleProductElementHost'></span></h3><p class='articleProductElementParagraph'>The code below correctly finds the local maximum of an array, but it fails to find the local minimum.  I have done web searches to find best methods for finding ...</p></div></td></tr><tr><td><div class='articleProductElement'><h3 class='articleProductElementTitle'>33. <a href=''>Algoritm to launch methods defined in xml</a><span class='articleProductElementHost'></span></h3><p class='articleProductElementParagraph'>I'm new to java. 

I have game levellogic implemented with timer. 

In my game i'm checking on which second of a level we are and then spawn enemies and  do ...</p></div></td></tr><tr><td><div class='articleProductElement'><h3 class='articleProductElementTitle'>34. <a href=''>Fast factoring algorithms?</a><span class='articleProductElementHost'></span></h3><p class='articleProductElementParagraph'>How can I quickly find all factors of a number?


  digit: 20<br>
  factors: {1*20, 2*10, 4*5, 5*4, 10*2, 20*1}
 </p></div></td></tr><tr><td><div class='articleProductElement'><h3 class='articleProductElementTitle'>35. <a href=''>Please discussing my Java code to find Factors(It's Correct?)</a><span class='articleProductElementHost'></span></h3><p class='articleProductElementParagraph'>Do  you  have  another  solution for solve Factor problem?
 </p></div></td></tr><tr><td><div class='articleProductElement'><h3 class='articleProductElementTitle'>36. <a href=''>custom partition problem</a><span class='articleProductElementHost'></span></h3><p class='articleProductElementParagraph'>Could some one guide me on how to solve this problem.

We are given a set S with k number of elements in it.

Now we have to divide the set S into ...</p></div></td></tr><tr><td><div class='articleProductElement'><h3 class='articleProductElementTitle'>37. <a href=''>Hindley-Milner algorithm in Java</a><span class='articleProductElementHost'></span></h3><p class='articleProductElementParagraph'>I'm working on a simple dataflow based system (imagine it like a LabView editor/runtime) written in Java. The user can wire blocks together in an editor and I need type inference ...</p></div></td></tr><tr><td><div class='articleProductElement'><h3 class='articleProductElementTitle'>38. <a href=''>How to implement an algorithm with pointers and memory allocation in Java</a><span class='articleProductElementHost'></span></h3><p class='articleProductElementParagraph'>I have an algorithm in C++ and I need to implement something similar in Java. I'm having trouble with memory allocation. How can I migrate the following snippet for example, from ...</p></div></td></tr><tr><td><div class='articleProductElement'><h3 class='articleProductElementTitle'>39. <a href=''>Trust metric implementation in Java</a><span class='articleProductElementHost'></span></h3><p class='articleProductElementParagraph'>I am developing a web application where registered users can upload their data and other users (registered or un-registered) can search for specific keywords and retrieve corresponding data; these users can ...</p></div></td></tr><tr><td><div class='articleProductElement'><h3 class='articleProductElementTitle'>40. <a href=''>Detecting equivalent expressions</a><span class='articleProductElementHost'></span></h3><p class='articleProductElementParagraph'>I'm currently working on a Java application where I need to implement a system for building <a href=BPF expressions. I also need to implement mechanism for detecting equivalent BPF expressions. Building ...

41. Algortithm to store Item-to-Item-Associations

I need some help to store some data efficiently. I have a large list of objects (about 100.000) and want to store associations between this items with a coefficient. Not all ...

42. bouncycastle provider can't find classes needed for algorithm

I'm trying to use bouncycastle to encrypt a file using a public key. I've registered the provider programatically:

Security.addProvider(new BouncyCastleProvider());
I created the public key object successfully. when i get to encrypting the file using ...

43. Versioning of domain model

I implement versioning for my own domain model (tracking of differences in objects during update operations). Domain model has a tree structure. E.g. (-> is reference)

|-> B
|-> C -> A

44. How can I prove that one algorithm is faster than another in Java

Is there anything in Java that would allow me to take a code snippit and allow me to see exactly how many "ticks" it takes to execute. I want to ...

45. A* Algorithm Bug

I tried creating the A* algorithm in java and I have this strange bug. I know the A* doesn't always find the best path, but here it seems to go against ...

46. Problem with a challenging algorithm

I'm stumped. I need to access the next nth row in a query loop to show version differences between posts. I'm using <cfquery> to output the revisions by group, and this is ...

47. Problem with Divide and Conquer Maximum Consecutive Subarray (MCS)

I want to find a nonempty, contiguous subarray for a given input array of integers, that can have duplicate values. I tried the divide and conquer method to find the maximum ...

48. There is a entity recognizer classifier algorithm that doesn't needs entire texts for training data?

I want to recognize some entities on texts that I have and I found a lot of algorithms (NaiveBayes, Hidden Markov Models, Conditional Random Field, etc.), but seems that almost all ...

49. Java - algorithm to find executable lines of code

I wrote a java program which scans and finds Executable lines of codes (ELOC), blank lines of codes(BLOC) and comments (CLOC) for only java and c++ codes. Following is my code:


50. Circle In Rectangle Packing Algorithm

I need a packing algorithm that fits a set of circles of varying radii, if the circles fit, in a rectangle. I've seen various pages on Wikipedia ...

51. What's the equivalent 'nth_element' function in Java?

I don't want get a sorted array, just nth element's value. For example, given the array

 a = [20, 5, 1, -3] 
I'd like to be able to ...

52. Java - How to build unique object tuples (n-dimension)?

I have the following challenge that I need to create unique object tuples out of object lists. The speical challenge is here how I can do it for dynamic list sizes ...

53. Java Algorithm to solve vendor machine 'change giving' problem

As a graduate I went for an interview for a java development role and was doing pretty well in the technical examinations until i came up against this question. If i was ...

54. Elegent way to write criteria based if statements

I'm trying to find an object in a list based on a set of criteria. The basic logic looks like this

for (objectx obj : list)
    if (object.property1 > ...

55. Theory behind Implementation of a Challenge 24 Solver

As an introduction to Java and android development I decided to write a Challenge 24 (given 4 numbers, must add, multiply, divide or subtract in order to create the product 24) ...

56. HMAC-SHA256 Algorithm for signature calcualtion

I am trying to create a signature using the HMAC-SHA256 algorithm and this is my code. I am using US ASCII encoding.

        final Charset asciiCs ...

57. First Come First Serve Algorithm Implementation

This is a project given to us by our professor. The requirements are to implement 3 pre-picked algorithms of CPU Scheduling in JAVA. our group was given FCFS(First Come First Serve),Round Robin,and MFQ(Multi-feedback ...

58. Parsing Tree-structure into Relational-style data-store

Would someone be able to help with how I could implement this, or at least the algorithm to use for this. What I am trying to do is parse a a hierarchical/tree ...

59. Keeping data in memory, Design approach

I have a problem where in I need to process some files with size in the range of few kbs up to 1 GB max. The use case is such that ...

60. Missing Date Ranges

I need to find all the missing date ranges from the rest of the year given a collection of date ranges. All the date ranges fall within the same year. And ...

61. The Bankers Algorithm for Deal or No Deal

I am going to make a game called Deal or no deal using Java. Can anyone give me the idea or the algorithm of how banker offers? Or the algorithm for ...

62. Mondrian Olap drilldown algorithm

I didn't found but may be someone could me explain - OLAP cube is a combination of all possible aggregation, so related to Mondrian - leaf level is data in fact ...

63. How to implement trim exceptional data like this?

I have a List<Data> that contains random objects: i and o characters. The Data has two types, i and o (Data.type). I want to write a function in Java that can arrange the ...

64. kadane algorithm in java

I have the following implementation of Kadane's algorithm in java. It is basically to find the maximum sum of contiguous subarray.

String[] numbers = string.split(",");

65. Moving average/total algorithm

I need to keep track of the last 7 days work hours in a flat file reading loop. It's being used to measure 'fatigueability' of work rosters. Right now I have something ...

66. Converting dungeon algorithm from java to javascript not working

I am trying to convert this dungeon algorithm from java into javascript, however, my script works 70% of the time. When it works, the problems are: the rooms ...

67. How can I build an algorithm to classify an HTML page based on keywords?

I'm trying to create an algorithm that set some relevance to a webpage based on keywords that it finds on the page. I'm doing this at the moment: I set some words and ...

68. Java backtraking problem

Hey guys. I've been strugling with a backtraking problem for hours. Can anyone lend me a hand? Here is the problem: n camels numbered from 1 to n are the arranged order. ...

69. Any ideas of what more web page meta information I can use to classify a page relevance for some theme?

I'm doing an algorithm to classify the relevance of a page for some theme like 'movies' using all meta information as possible, but excluding the textual content of the body. I want ...

70. Algorithm for software keystone correction

As part of my software I'm looking to write a keystone correction filter to avoid the tombstone / keystone effect you can get when projectors are displayed at an angle not ...

71. k combinations from n

Possible Duplicate:
Algorithm to return all combinations of k elements from n
The combination can be formed with 3 digits from 1,2,3,4 such a way that ...

72. Coding Kata : What is the optimal algorithm to solve this

I was trying to solve random coding kata's and found this one, my question here is what is the optimal algorithm and best design approach for solving this kata? Given a sequence ...

73. need help in designing algorithm for syntax analyzer

I want to create a program for syntax analyzer for java, but I'm confusing in what way I should design the algorithm? can you please elaborate...

74. How to find the base10 of (x:g)?

I am at the end of my homework, and a little confused on the right way to go for this algorithm. I need to find the base10 of a number:base that ...

75. Looking for resources for moving around in grids/cells

I'm making a simple enough game that involves using a grid, very much like a sudoku style grid, but I am having an extremely tough time figuring some seemingly simple things ...

76. Locate triangle containing arbitrary point in Delaunay-triangulated surface

I'm looking to do a linear interpolation of a irregularly sampled function z(x,y) based on a Delaunay triangulation. Say I have a hill for which I have obtained a Delaunay triangulation: ...

77. Script for Dropbox to make a automatic process

Hope you all know about Dropbox. In Dropbox, we can drag the files to drop box folder then it will be stored in the cloud. I need to do this ...

78. How obtain first/last day of an incomplete week in Java

and thanks for reading me. I have a little problem that is that I need to Know the first/last day of a week in a month and a year, so:

public String getFirstDayOfWeekAndMonth(int ...

79. Where/how can I allow non-numeric values in my program?

I am making this little program using command line arguments, I have like 90% of the work done. But I am trying to allow the user to enter non numerical values ...

80. How can i make sound in Java? Which exactly sounds like my voice, clone my pronounciation

I mean by "make sound" which sound never exist, its completely made in Java. I am trying to make a very simple very basic hello real world code in Java, but cant ...

81. Add business hours to Java DateTime

For an issue tracking system I need to calculate the response time for a request. The timer for response time should only be running during business hours. What algorithm/library should I ...

82. How to validate Battleship field?

I am trying to validate battleship field with these rules:

  • Ships don't touch with sides or corners;
  • Ships are straight;
  • There are 1×4-deck ship, 2×3-deck, 3×2-deck, 4×1-deck ships.
The field is represented as ...

83. Finding a particular Set of SubSets of a PowerSet in an efficient way

I'm trying to find an efficient way to grab a Set of Subsets of a PowerSet. For example, this works when the set sizes are small:

Set<Integer> set = new HashSet<Integer>();

Set<Integer> set2 ...

84. How to create your own security provider with some crypto algorithm?

Using official tutorial i understood the main principles of Java Cryptography Architecture. But neither the officials nor internet gives me anything distinct about creating my own provider and implementing some crypto algorithms. I ...

85. Algorithm to find all possible 'StringPairGroups' in Java?

Mathematics/algorithms was never my strong point (!) so requesting help on this one. What is the most efficient implementation for a method with the following signature:

 * pairParts.size() > 0
 * pairParts.size() ...

86. Java vs. JavaScript(HTML5), The Distributed Algorithm Animator

In my final year project I have to build an Algorithm animator. It would be done to show how the algo works using nodes(PCs) and edges(connections). For example, how the leader ...

87. Open Source implementation of a Spaced Repetition Algorithm in Java

I work on a project where Spaced Repetition is essential, however I am not a specialist on the subject and I am afraid to reinvent the square wheel. My research pointed ...

88. Algorithm to output the initials of a name

I have just started the java programming and at the moment I am doing the basic things. I came across a problem that I can't solve and didn't found any answers ...

89. Finding Duplicates of a set of millions

Possible Duplicate:
Algorithm: efficient way to remove duplicate integers from an array
I would like to know what is the best, efficient approach for finding a ...

90. How to scan hundreds of log files containing SSN, and change the files to mask out the SSNs without changing the reset of the contents

I was asked this question on an interview and I couldn't came up with an efficient idea to solve this problem. "How to scan hundreds of log files containing SSN, and ...

91. Assigning a value for each day for the past 2 weeks using 14 buckets to store them

This is kind of hard to explain but I need to come up with an algorithm that will use these 14 value buckets to move through it based on the day ...

92. Java algorithm to track parts of aggregated values

My program have evaluate hundreds of millions of records. So the question of memory and performance are important. Lets each record has key - ticketID. Also record has field value and field ...

93. How to count identical bytes

I have two long arrays of bytes and I need to compute how many bytes on corresponding positions are identical. My solution (in JAVA) is as follows:

    int ...

94. Gift Wrapping Algorithm not working properly

I am trying to implement this Gift Wrapping Algorithm (yoshihitoyagi!) done in java, in VB6. I'm pretty sure I have done this properly, but for some reason, it will ...

95. RLE sequence, doing a tailReplace

If I'm constructing a tail replace method for an RLE sequence, is the best way to decompress the sequence, append the new sequence at the given index, and then recompress or ...

96. Brute-Force language detection

I need an algorithm (any programming language) to test the vitality with an hill climbing algorithm for breaking a cipher for a crypto challenge. The algorithm should test how likely it ...

97. Updated: subsetSum

Trying to write algorithm for subsetSum... It should find all possible subsets of a given vector, then find which ones add up to a target value. However, I keep getting nullpointerexceptions, ...

98. algorithm, in java?

I need help with an algorithm to search for query words, in isolation and/or in combination, assign a score to each match and sort the matches by score. The returned results ...

99. Absolute newbie to java

Hi i have been given a task for my course and it is to create an algorithm to make a 5 by 5 square like below:

Ive spent hours attempting to do ...

100. Outputing a square to console in java

Hi i am doing my coursework and i have been given the task is to make an algorithm for a square that's 5x5 using "*" but has to be filled in ...  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.