algorithm 6 « algorithm « Java Collection Q&A

Home
Java Collection Q&A
1.algorithm
2.array
3.Array Byte
4.Array Char
5.Array Convert
6.Array Dimension
7.Array Integer
8.Array Object
9.Array String
10.ArrayList
11.collection
12.comparator
13.Development
14.Garbage Collection
15.Generic
16.hash
17.HashMap
18.HashTable
19.iterator
20.LinkedList
21.List
22.Map
23.queue
24.Set
25.Sort
26.tree
Java Collection Q&A » algorithm » algorithm 6 

1. Spiral in Rectangular algorithm, Please help!    forums.oracle.com

1. If your final objective is to draw the points on a graphical device, consider directly filling a square instead of drawing each single point. 2. if you're interested in the coordinates only, then you will not get a rectangle. I tried doing the painting manually on MS Paint. You should try, too, and see if you can get a rectangle. ...

2. Little Algorithm help    forums.oracle.com

3. Help needed in algorithm design please    forums.oracle.com

Hello, I need to design an algorithm that prints a monthly calendar in tabular format. The problem is: 1. The first day of the month needs to be indented to the corresponding day of the week, 2. Each week needs to be on a separate line (Sun ... Sat), How should I design this? What data structure should I be using? ...

4. Data integrity algorithm undecided    forums.oracle.com

I need some advices related to data integrity checking. I am implementing a database like routine witch SELECTS and INSERTS data into a custom database. I am still thinking of how to implement in a good way indexes and data integrity. But this question is related to data integrity, to be more specifically I don't know what kind of algorithm to ...

5. Trouble understanding KMP algorithm    forums.oracle.com

If anyone is familiar with the KMP skip search algorithm and cares to shed some light on the subject. I am having trouble understanding how the table is derived, as many examples i come across seem to be using different variations. The table used to control the search. Thanks a million in advance, Mel

6. Min MAX Algorithm Problem.    forums.oracle.com

7. Algorithm    forums.oracle.com

8. Warshall's Algorithm    forums.oracle.com

9. Fair Teams Algorithm    forums.oracle.com

You have stated an interesting problem. One thing you do not say is if you want the gamers to all be approximately the same strength or if just the over all team strength is to be considered. 1 -- all about the same strength on a team (fairly easy) what ever attributes you score the relative strength of each player by, ...

10. Ullman algorithm    forums.oracle.com

11. Algorithm to Scatter Points on a Canvas    forums.oracle.com

I am working on a project which is to emulate Dijkstra's algorithm (as seen in OSPF). I have chosen to create a GUI (above and beyond requirements for the project) which will plot a given number of routers out on a canvas and show all the links between them. Since this is purely a 'personal touch' to the project I do ...

12. Algorithm for Uni    forums.oracle.com

No, that really wasnt what i was asking. As i said i have tested it pretty thouroughly, and it doesnt throw any errors. All i mean was anyone who can see at a glance that this might skip the first entry or last entry or whatever. (it doesnt) Obvious logic errors that i have made. I was not expecting anyone to ...

13. Bit operation algorithm    forums.oracle.com

Hi everyone! I am currently developing a chess game in java and I was wondering if anyone had some insights into the best way to do the following: I have a long number (however, it could as well be an int or a byte, doesn't matter) and I have a pointer on one bit in the number (can be anywhere and ...

15. Bomberman AI algorithms    forums.oracle.com

16. magic square algorithm    forums.oracle.com

17. Next Day Algorithm    forums.oracle.com

There are a lot of correct ways to handle it however there is very few efficient ways. The way i would handle the months with 30 days is an if statement that looks for nextDay.month==4||nextDay.month==6, etc would a switch be better for that just looking for the best way to go about it

18. I Need Java code for following Algorithm    forums.oracle.com

int numTokens = 0; StringTokenizer st = new StringTokenizer(s1); String[] a = new String[10000]; String[] br_n=new String[10000]; int i=0; while (st.hasMoreTokens()) { s2 = st.nextToken(); a=s2.substring(0,s2.length()-3); s6=s2.substring(s2.length()-2); br_n=s6; i++; numTokens++; } int numTokens1 = 0; StringTokenizer st1 = new StringTokenizer (s3); String[] b = new String[10000]; String[] br1_n=new String[1000]; int j=0; while (st1.hasMoreTokens()) { s4 = st1.nextToken(); b[j]=s4.substring(0,s4.length()-3); s7=s4.substring(s4.length()-2); br1_n[j]=s7; j++; ...

19. out of memory - what to do? (memory complex algorithm)    forums.oracle.com

if i set the heap size to 1.2gb the programm is able to handle larger problems but it is easy to get a problem where 1.2gb isn't enough. and i am sure that the code only saves references to objekt - that was a problem/bug that i had to fix in later steps. after the cartesian product is built i have ...

20. is this how to program an algorithm which uses modular arithmatic?    forums.oracle.com

if ( (x-a)^n is not (x^n-a) (mod x^r-1,n) ) then output COMPOSITE from [http://primes.utm.edu/prove/prove4_3.html|http://primes.utm.edu/prove/prove4_3.html] a, n, and r are define variables. x is part of a polynomial (I'll use [this|http://www.cs.princeton.edu/introcs/92symbolic/Polynomial.java.html] to handle the polynomial type variables). My question is, how do I program for modular arithmetic? Does this do what the above pseudocode does? [ (x-a)^n]-[(x^n-a)]% (x^r-1) != 0 && [ ...

21. "Branch and Bound" algorithm    forums.oracle.com

Sounds like you might want a simple greedy algorithm. Sort by filesize, then start adding the largest files; if one would put it over the limit, skip it and try the next. Of course, it may not always be optimal - but it'll be a heck of a lot easier to implement and take a heck of a lot less time ...

22. Developing nonrecursive algorithm for combinations with repetitions    forums.oracle.com

For one of my projects, I need to produce all combinations where you choose k objects, having n possible objects to choose from. I have two uses for this, one where I need to produce all combinations of numbers, and one where I need to produce all combinations of Objects. However we're talking k=27, n=20 which is a very big number, ...

23. Very Hard algorithm problem    forums.oracle.com

My algorithms knowledge isn't that bad but I don't understand the problem. From what I understand you have n digits given in a String. You supply and arbitrary number m encoded in those supplied digits and you want to get the number k+m also represented in those digits? Right? I still don't see the problem except for a bit of en/decoding ...

24. Java Algorithm problems?    forums.oracle.com

Im writing a simple calculator program and somehow the algorithm gets stuck on my nerve as i've been around the problem for so long. The problem is that i dont know how to implement an algorithm for the dot(.) operator. How do i write it so that when we press numbers and then press the dot operator and finally press another ...

25. Whats the best 'guided missle' algorithm to use in 2d space?    forums.oracle.com

Hey, I'm trying to figure out how to move my object towards a given coordinate, just as a guided missile. I know the following stuff: - my location, x and y - destination location, x and y - previous last locations, x and y (i can simply just save them) Problem is that, I don't know my own direction (angle). This ...

26. Question about KeyStore algorithms    forums.oracle.com

27. general algorithm for cartesian product    forums.oracle.com

this paper i downloaded allready its an application of "cpa". its an algorithm that uses cartesian product of special (sub)sets. what i want is much easier. i want only the cartesian product - the question is, is there an algorithm better than using one while loop for everey set and everey loop loop throu each set.

28. Tiny Encrytion Algorithm (TEA)    forums.oracle.com

public String encryptForLoadTest(String val, String key) { Cipher cipher = null; byte[] encrypted = null; try { // Step 1: Add the Bouncy Castle Security Provider Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); // Step 2: Key Specifications byte[] byteValKey = hexToBytes(key); SecretKeySpec keyspec = new SecretKeySpec(byteValKey, "XTEA"); // Step 3: Cipher specifications cipher = Cipher.getInstance("XTEA/ECB/ZeroBytePadding", "BC"); cipher.init(Cipher.ENCRYPT_MODE, keyspec); // Step 4: Encrypt the input String ...

29. Brute Force Algorithm    forums.oracle.com

here is an encryption program. I am wanting to make a program that will brute-fore attack the encryption that this program spits out (you know, trying every letter combination aaa, aab, aac, etc) i am only going to do 3-4 characters all of which are letters. how can i do this brute force program? Thank You

30. cross selling algorithm    forums.oracle.com

I would be thankful if you can tell me exactly where in that cross selling concept is used in that doc. cross selling- Cross selling is the inbound telemarketing technique used to inform a customer of a related item that naturally "goes" with the main product. For instance, a customer that just made a computer printer purchase may be interested in ...

31. bankers algorithm problem need help!!!!    forums.oracle.com

32. Java Algorithm    forums.oracle.com

Simple enough but I need a rule to say that if the percentage value of any of the constituent objects exceeds say 5% to distribute the remaining quantity (in this example 45%) evenly across the other objects in the list. Each will have to be check again for the 5% rule until all are below 5% or a maximum number of ...

33. Algorithm Give All Possible Boolean Arrangement of N Variables?    forums.oracle.com

Hi, I need help with a method that can store an arraylist of all possible T/F arrangement for some variables. For example, 3 variables A,B,C A - B - C T - T - T T - T - F T - F - T T - F - F . . . . . . . . . I need ...

34. Algorithm required    forums.oracle.com

Innovationneverstops wrote: I need a help to write one algorithm. The scenario is like this, Please change your sign-on name to cross-posting-never stops. Unless you want to upset folks here so that no one will want to help you, please stop cross-posting the same question in multiple forums. Can you imagine the frustration of putting in volunteer effort to help someone ...

35. Algorithm required    forums.oracle.com

36. Help with problem implementing Gauss type algorithm    forums.oracle.com

I'm working on a Project for my class and am writing the code for one of Methods in my EasterClass which is the programmer class. The program is supposed to compute the d I found the remainder method of in standard class library as the directions state I need to get the remainder of the divisions i have to do and ...

37. Frustrating little algorithm    forums.oracle.com

I would help, but I don't see what your algorithm is supposed to do. You say you're iterating through a series of numbers and keeping track of the highest one you come across? your sample output doesn't really show that.... 3...3 3...5 is the left 3 input? why are you printing 5? I can help - but I need to know ...

38. Modify A* Algorithm    forums.oracle.com

/** * Adds the node at {@code x}, {@code y} to the open list, using {@code parent} as the parent. * *

* If the node was already added to the open list, the old value is either kept or replaced, * depending on whether the old one is closer to the origin or not. *

* * @param ...

39. Implemented Easy Pass Algorithm?    forums.oracle.com

40. pagination algorithms?    forums.oracle.com

We know the functionality Word provides - the question is with a "document" composed of paragraphs, tables, images, & newspaper columns, where do we break each page, and what is the most effective way to do this. Some of the issues we hit is autofit table width where we have to re-calculate several times the content of the tables to find ...

41. more efficient algorithm in a map-related problem    forums.oracle.com

Hi all, I've got a problem that I've been trying to come up the most optimised solution. Say, I have a mapping relationship as below. key -> value {a, b} -> A {a, b, c} -> B {a} -> C {b, c, d} -> D {b} -> E .... The problem is that, given a set of elements, such as a, ...

42. DES algorithm (Read and Write bytes to file)    forums.oracle.com

Since you say the implementation you are using is treating bits as Strings I must assume you have borrowed the code without asking permission since nobody would want to implement DES this way and then to admit to writing it and allow it to be released. The JCE has an implementation of DES using bytes (8 bytes at a time).

43. HELPP PLEASE i need help solving this algorithm please!!    forums.oracle.com

Read the following algorithm for the recursive procedure called Mystery. MYSTERY(soFar, toGo) length = LEN(toGo) IF length = 1 THEN PRINT soFar & toGo ELSE FOR i = 1 to length MYSTERY(soFar & MID$ (toGo, i, 1),LEFT$(toGo, i 1) & RIGHT$(toGo, length i)) NEXT i ENDIF END of procedure Where: LEN(aSTRING) returns the number of characters in the string ...

45. Cannon's algorithm's block multiplicaiton    forums.oracle.com

A(1,1) [7 8] [9 10] B(0,0) [5 6] [7 8] B(0,1) [7 8 ] [9 10] B(1,0) [1 2] [3 4] B(1,1) [3 4] [5 6] C(0,0) [a b] [e f ] C(0,1) [c d] [g h] subblock A(0,0) 1 2 3 4 multiply with subblock B(0,0) 5 6 7 8 and put the result back to C(0,0) C(0,0)=A(0,0) *B(0.0) the ...

46. watershed algorithm (Vincent and Soille)    forums.oracle.com

47. Help me with an algorithm    forums.oracle.com

So, given this input data, I need to create a new List each member of which is the concatenation of a unique combination of elements from each of the constituent sets in the input constructed starting with the first set and which contains all such combinations.. So, for this data, the result list would contain these 24 strings:

48. Developing a Payroll System with NSD - A simpler algorithm in Java?    forums.oracle.com

Hi, I've been trying to develop a payroll system but I'm having some challenges on "trapping" the Night Shift Differential for all shifts. I'm from the Philippines and our NSD starts from 10pm - 6am by law. This payroll system is supposed to accept any shifts: day or night; 8-hour shifts, more or less than 8-hour shifts... making it dynamic in ...

49. Message Digest Algorithm    forums.oracle.com

StringBuffer hexStringB = new StringBuffer(); //Save or print digest bytes. for (int l=0;l

50. algorithms    forums.oracle.com

In mathematics, computing, linguistics, and related disciplines, an algorithm is a definite list of well-defined instructions for completing a task; that given an initial state, will proceed through a well-defined series of successive states, eventually terminating in an end-state. That was taken from the wikipedia page for Algorithms. I just see an Algorithm as a way to do something. as in ...

51. Algorithm modelling problem    forums.oracle.com

Hi, I am trying to implement Jakobsens fast approach to cryptanalysis in Java... I have the algorithm sorted on paper that i want to use but i am not sure of the best way to implement it in Java... I have these variables set up... Di, ki and bestKey are arrays... this.Di = this.biPerc.clone(); this.bestKey = iKey.clone(); this.ki = this.bestKey.clone(); int ...

52. Diff algorithm    forums.oracle.com

Hi All , Given 2 files , how can I get the differences between them ? what I did is that I checked 4 words after any difference occured . That is check the neighbors. Example( just see the words ): string1: I am in the new forum of C from 6 am morning. string2: I am Tom in the new ...

53. help with bubble sort algorithm?    forums.oracle.com

basically the method has to go through the array, comparing the first two numbers in the array, and swap them if the 1st number > 2nd number. then compare the 2nd and 3rd numbers in the array, and swap them if 2nd > 3rd, and so on all the way through the array. it has to repeat this process however many ...

54. Similairyt check algorithm    forums.oracle.com

55. Iterative Postorder Traversal algorithm for Huffman Coding    forums.oracle.com

Hello, I am working on an implementation of Huffman encoding. Unfortunately, the book I have is written in C so I am having a tough time working things out in Java. After a bit of struggling, I have everything working using recursive postorder traversal. Now the last step would be to use iterative postorder traversal instead. Does anyone have the algorithm ...

56. Brute Force algorithm    forums.oracle.com

Thanx for all replys, yet nothing that is of any use tho The first reply aint of much help as I dont see how to implement it into my code.. petes1234 said: it seems to me that since every char (changed to an int implicitly) is multiplied by i and by 4 and then added together, all results have to be ...

57. Triangularization Algorithm    forums.oracle.com

Actually my problem is that i want to a create a (M x M) grid table which allow the user to maniuplate the cell by clicking on it to have a cross on it or left it empty.In the end the cells in the grid table that has a mark on them, i need to use these algorithm methods called trianggularization ...

58. algorithms that jvm follow    forums.oracle.com

59. Problem with Zooming Algorithm    forums.oracle.com

It could be anything that is paintable for the panel. What I did is 1. Calculate the distances between the center point and location of each element in the panel, and then multiply by the current scale. 2. Re-calculate the location of the element based on the new distance. 3. Re-calculate the width and height of the element based on the ...

60. Having some trouble with some algorithms    forums.oracle.com

thanks that gives the algorithms i think i have them now but the problems im having are with the 12 percent charged each year I think that 12% a year compounded monthly is simply equivalent to 1% a month. The true yearly interest will be different due to compounding. and the output not stopping when the balance is zero It is ...

61. c algorithm to java    forums.oracle.com

62. knights tour algorithm    forums.oracle.com

You don't expect us to debug and write your program do you, because thats the only way to solve the problem. Try searching the forum. I've seen questions on this topic before (either in this forum or the Swing forum). Then you can compare the code in the other posting with yours.

63. mathematical algorithm in java    forums.oracle.com

64. Multidimensional Scaling Algorithms?    forums.oracle.com

65. Prim's Algorithm...Help me!    forums.oracle.com

Prim's Algorithm Problem: Determine a minimum spanning tree. Inputs: integer n>=2, and a connected, weighted, undirected graph containing n vertices. The graph is represented by a two-dimensional array W, which has both its row and columns indexed from 1 to n, where W[ i ] [ j ] is the weight on the edge between the ith and the jth vertex. ...

66. LZW Algorithm example    forums.oracle.com

67. LZW algorithm - Dictionary    forums.oracle.com

Hi, Currently working on a project in which I have to demonstrate LZW encoding and decoding some texts. For a starter im currently working on the Dictionary. I am wondering would a Hashtable be the best option for storing the values of the dictionary as I can Hashtable(); Allowing me to have pointers to all my strings in the dictionary, and ...

68. How do you implement an algorithm?    forums.oracle.com

/** Task: Indicates the precedence of a given operator. * @param operator a character that is (, ), +, -, *, /, or ^ * @return an integer that indicates the precedence of operator: * 0 if ( or ), 1 if + or -, 2 if * or /, 3 if ^, -1 if * anything else */

69. java.security.NosuchAlgorithmException: Algorithm DESede not available    forums.oracle.com

bauc52g0:gxcdb:gxcadm 2> ls -lrt total 104 -rwxr-xr-x 1 bin bin 2212 May 12 2004 local_policy.jar -rwxr-xr-x 1 bin bin 2199 May 12 2004 US_export_policy.jar -rwxr-xr-x 1 bin bin 6593 Oct 16 19:49 java.security -rwxr-xr-x 1 bin bin 2652 Oct 16 19:49 java.policy -rwxr-xr-x 1 bin bin 30337 Oct 16 19:49 cacerts bauc52g0:gxcdb:gxcadm 3> ******************* The results seem identical. Can you please ...

71. Java algorithm for calculating closest point    forums.oracle.com

72. Kindly help me out with viterbi algorithm coding....    forums.oracle.com

try this.... import java.applet.Applet; import java.awt.*; public class Viterbi extends Applet { public void init() { option = 1; n_cmfile = 1; n_type = 1; Vit = new Diagram(); add("North", EnterWord); add("North", Word); add("North", Run); add("North", Clear); add("North", ValuesMenu); ValuesMenu.addItem("Table"); ValuesMenu.addItem("Trellis"); add("North", TypeMenu); TypeMenu.addItem("Conf. matrix I"); TypeMenu.addItem("Conf. matrix II"); TypeMenu.addItem("Conf. matrix III"); TypeMenu.addItem("Conf. matrix IV"); show(); } public void paint(Graphics g) ...

74. weird code algorithm with ClassLoader    forums.oracle.com

75. garbage collection algorithms    forums.oracle.com

Promotion copies the actual object. Whether that takes a huge time depends on how many objects survive in a program, and what you consider "huge" anyway. You can run with -verbose:gc to see collection times; usually minor collections are fractions of a second. The parallel collector (-Xincgc) makes the pauses shorter if you have a program that suffers from visible pauses. ...

76. What are some algorithms and utils good to know?    forums.oracle.com

I am trying to improve my overall programming skills by creating an API of various helper methods that can be used in day to day programming. So far, I have written my own implementation of the Java Collection Framework. What are some other useful utils to write? Like how to find a string (forward and/or reversed) within a body of text. ...

77. Simplicity of Ratios? Algorithms for Music Generation?    forums.oracle.com

Okay, this isn't really a Java question so much as a math / algorithms question. I'm researching something for my brother. He apparently has been reading some paper on programmatically generating / writing music, and they describe consonance and dissonance in terms of the simplicity of the ratio between notes in an interval. Unfortunately, he can't (and I can't) find a ...

78. connect four algorithm    forums.oracle.com

What do you mean by a "connect four algorithm"? Do you mean the game "Connect Four" or do you want to try to connect four pieces of data, or four points on the screen, or four files on the hard drive? The possibilities are endless. Are you asking other people to do homework for you, or are you working on a ...

79. Finding a non-recursive algorithm    forums.oracle.com

But I am curious how someone would go about implementing a NON recursive algorithm. I understand it would probably be around 2000 lines to implement it. I am not asking anyone to implement it, nor do I plan on it (well..I may one day if I am bored) I am only asking for mere curiosity how someone would go about implementing ...

80. Custom Algorithm    forums.oracle.com

public void Compute() { int i; String bilum = codeIn.getText(); int c = bilum.length(); String[] balus = new String [bilum.length()]; try { dostuff(balus); } catch (Exception ex) { ex.printStackTrace(); } return; } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MyFrame().setVisible(true); } }); }

81. Java Algorithm Program help    forums.oracle.com

82. Stepping through an algorithm - can't do it in java?    forums.oracle.com

I'm sorry. I'm really not that comfortable with EventQueue.invokeLater() even though I've read about invokeLater(). Would you please explain how exactly to use it in this example? It's pretty much the same as starting a thread. You create a Runnable object and pass it to invokeLater. That puts it on swing's TODO list and, at some point in the not too ...

83. algorithm practice    forums.oracle.com

84. Tracing algorithm    forums.oracle.com

85. Algorithm problem    forums.oracle.com

I would be interested to know, what way you would do the following? Determine how many words in a dictionary contain the same letters and report by the number of hits at each word length; in the most efficient way. Write Java code to show the solution. You will be expected to present the algorithm for the solution at the white ...

86. Need help in Java Algorithms and DS    forums.oracle.com

2> I have an Array of 10,000 unsorted elements with duplicates ,For example : Array a = [1,2,3,4,5,5,6,7,8,9,1,2,3.......upto 10,000 elements] How will you find duplicates and list the duplicates in case there is an Array of 10,000 unsorted elements with duplicates.Ensure the performance is taken care in your solution. Could you help me out with sample code forr this algorithm implementation. ...

87. Randomization algorithm    forums.oracle.com

thanks for the suggestion . I'd like to mention that i need this algorithm for time table generation system that i am trying to implement. Although i came up with the idea of how to use the random class for this but given the number of possible constraints,the complexity of implementation,the code i will write will become very difficult for future ...

88. Looking for a simple example of the Minimax algorithm in java    forums.oracle.com

Hey everyone, I'm currently working on a Gameboy emulator program as a pet project, and for one of the game's I'd like for the enemy AI to use the Minimax algorithm, but I don't have any experience with it (or recursion in general, for that matter). Could anyone maybe post a simple example of how this algorithm works?

89. Distance Algorithm. Please help!    forums.oracle.com

I need to find an algorithm for calculating the closest point to each point contained in a given array. That is, for each point in an array of randomly generated points, I need to find the point closest to it other than itself. I already have a basic algorithm to solve this, but it compares the distances between the current point ...

90. Algorithm help needed for electrically charged metallic sphere simulation    forums.oracle.com

I am making a simulation program using Java which takes into account the gravity, air resistance as well as electrical forces of the two charged metal spheres. The user can input/select: 1) The initial velocity for each metallic sphere 2) The variables in g = MG/(r+h)^2 Newton's law of gravitation (so gravity is SLIGHTLY different per metallic sphere depending on the ...

91. WordSearch Solver Algorithm Help    forums.oracle.com

92. Chess algorithm?    forums.oracle.com

The idea behind my project is to project hints onto a real life game of chess. As far as specifics go: I need a jar library for a chess engine that I can interface with my program. I want it to allow me to instantiate a game, but to update it manually. (Not to play against me, taking the best move ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.