algorithm 4 « 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 4 

1. Source Code detection with Java    stackoverflow.com

Any idea how to detect a source code (Java, C#, SQL and so on) in a text file with Java without looking at the file extension or using an extraordinary long, ...

2. How to make Automated Online Assistant?    stackoverflow.com

I just saw Ikea's "Automated Online Assistant" and it looks pretty smart (for example I asked when one branch is open and it redirected me to correct page). Does it uses just ...

3. Beginning Dynamic Programming - Greedy coin change help    stackoverflow.com

I am currently working through a book on algorithm design and came across a question whereby you must implement a greedy algorithm with dynamic programming to solve the coin change problem. I ...

4. Trying to solve Codalility Algorithm    stackoverflow.com

I tried the sample demo at Codility website, and posted my soultion but I've a simple mistake but couldn't determine it. The problem is described here (The problem is only described please ...

5. Counting no of matrices with exactly n/2 zeros and n/2 ones in each row and each column for a given n    stackoverflow.com

For a blank n * n matrix, even n, we want to assign zeros and ones to this matrix so that each row and each column contains exactly n/2 zeros and n/2 ...

6. Java implementation for consensus algorithm    stackoverflow.com

I am working on a distributed systems and I have to implement consensus algorithm ( pref. Paxos ). I was looking for any API which I can use to have ...

7. transfrom Method is not getting call in MAIN method ?     stackoverflow.com

package edu.uci.ics.jung.algorithms.cluster;

        import java.util.ArrayList;
        import java.util.LinkedHashMap;
        import java.util.List;
   ...

8. Algorithm or Open Source implementation for custom Auto-Focus    stackoverflow.com

I've noticed that in some devices without true optical focus control, (Blackberries, Android phones, etc), there's a built-in digital auto-focus mechanism. I suppouse that this mechanism is fully implemented in software, applying ...

9. Divide and Conquer Hull Algorithm    stackoverflow.com

Hello my question today is to breakdown and figure out how to actually code the LOWER TANGENT part of the algorithm Ive managed to complete steps (1) and (2) but I ...

10. What is wrong with my selection algorithm?    stackoverflow.com

enter image description here So I spent a week on this, and asked my peers, but we couldn't get it right. I turned it in as is, just to be ...

11. need help writing an algorithm for this college task in java    stackoverflow.com

Spec Counting in Lojban, an artificial language developed over the last forty years, is easier than in most languages. The numbers from zero to nine are:

      ...

12. Implementing into Java (analysis of algorithms)    stackoverflow.com

Firstly i would like to say i dont want answers, just advice on how to go about achieving them, my main issue is how to implement both into java and compare ...

13. read vertices and creating edges    stackoverflow.com

For this task I'm supposed to create a "wannabe" network that is supposed to be a graph. The first file you read contains a textfile with vertices from/to and some other ...

14. Algorithm For Bullet Chart    stackoverflow.com

What is the best algorithm for bullet chart/graph visualization? Bullet Chart

15. Queen Domination    stackoverflow.com

I'm trying to, using stacks, find a solution for placing k queens on an n X n chessboard, where k is < n, such that each cell is attacked. I'm thinking ...

16. Optimize many Intervals in Joda Time    stackoverflow.com

I have a bunch of Joda time Interval objects ( http://joda-time.sourceforge.net/api-release/org/joda/time/Interval.html ) stored in a List. All of these Intervals have valid start and end instants. These Intervals can ...

17. A* Algorithm With Manhattan heureustic    stackoverflow.com

Am really stuck and need some help from you guys. Am implementing the NXN puzzel in 2-Dimensional array (using Java). My questions are: 1) How do i calculate the Manhattan distance in 2-Dimensional ...

18. How Can I determine The Direction To Move    stackoverflow.com

I am solving an NxN puzzle in java 2D array. I can move to the empty tile in say four directions : LEFT, RIGHT, DOWN or UP. My question is ...

19. Priority Queue Issue    stackoverflow.com

Am implementing the A* algorithm based on this tutorials:

create the open list of nodes, initially containing only our starting node
   create the closed list of nodes, initially ...

20. A*star Algorithm Implementation Is Not Working    stackoverflow.com

I am implementing the AStar algorithm with Manhattan heuristic but I haven't been able to get it working. I get infinite loop. The problem is in the search method. ...

21. Are there any opensource java libraries for Polyline simplification?    stackoverflow.com

Mainly the implementation for Douglas-Peucker algorithm.

22. Has anyone done a Java Applet for Addition-Reference-Bits Algorithm (One of the page replacement algorithms in Operating Systems)    stackoverflow.com

I want to develop a Java applet for the Addition Reference Bit Algorithm which is LRU page replacement algorithm. If anyone has already developed such a thing, it will be of ...

23. point localization algorithm    bytes.com

Hi all, I want to implement a 2D corrdinate system in Java so that i can get the corrdination for each point i chosse. i have seen alot of applet that ...

25. implementing DES algorithm    bytes.com

26. Reading a text file while controlling BIDI algorithm (visual BIDI)?    coderanch.com

Hi, I need to read some text files, containing Left-To-Right text(Hebrew and Arabic, yet the two languages never appear in the same file). Unfortunately, the files were written by some ancient homemade DOS program, some 20 years ago. It used the following algorithm: Char encoding : IBM CP 824 (Arabic) , IBM CP 826 (Hebrew). Ordering: 'Visual BIDI Ordering' , i.e. ...

27. Compression Algorithm    coderanch.com

Hi guys, I am coding a certain Swing application. This application is capable of saving data as files, which is a very common feature. However, I have a little problem here. After generating the saved file, I need to be able to open this file in a J2ME application. As a result, I will like to have this saved file consume ...

28. EAP-MD5 algorithm    coderanch.com

je veux implmenter une application client-serveur et je veux utiliser l'algorithme EAP-MD5 pour l'authentification. j'ai trouv la documentation suivante: The EAP-MD5 algorithm consists of the following basic steps : 1. The client sends the username to the server in clear text. 2. The server validates the username and sends the client a clear text message(called the challenge). 3. The client uses ...

29. Algorithm Help    coderanch.com

Hello everyone. I am writing a program that uses the Java Robot class to basically do all of the keystrokes that a human would do in order to complete a certain process. The Robot performs these keystrokes on another windows program. My goal is to basically find a certain folder from a very large list. I search for this folder by ...

30. Generic Algorithm    coderanch.com

A genetic algorithm is trivial in any programming language and so it easy to implement in Java. It is capable of finding global maxima much much quicker than other methods such as simulated annealing, as you can only jump between neighbouring solutions using a SA algorithm rather than around the entire search space with a GA (made possible through crossover). Consequently, ...

31. Algorithm-Please help guys!!!    coderanch.com

Hi, I have a problem at hand and i kinda need some help. I have an array with some values inside and basically i need to check if the array (index value+1) == the actual value in that index and if so, i need to increase a counter. int a[] = {-1, 0, 2, 4, 5, 6, 7} and the result ...

32. who uses algorithms they learned in cs classes?    coderanch.com

hi everybody, i am wondering: 1) does anybody here use any of the algorithms they were taught in their cs classes during their everyday java coding gigs? 2) what algorithms that you learned in your cs studies have you used recently? 3) if you haven't used any cs studies algorithms in your real-world jobs, why not? 4) if you do use ...

33. crypt algorithm    coderanch.com

I would suggest creating a hashtable with the initial string as the key and the string you wish to convert to as the value. For example, if a converts to t, Hashtable table = new Hashtable(); table.put("a", "t"); You can then take each letter from the word and us it to extract the value you wish to convert to. For example, ...

34. any algorithm suggestion?    coderanch.com

I am having a resource scheduling problem now. I have 5 trucks and coming new job orders, and I need to make a autorunning program that can automatically check the status of truck and assign coming new jobs to it. the problem is that not only I need to balance the service time of each truck, but also I have to ...

35. Walksat algorithm implementation    coderanch.com

hi fellows..... i am trying to write a program to solve class scheduling program....the problem is based on implementing the walksat algorithm or hill climbing algorithm.....i have looked at these algorithms but unfortunalely i was not be able to understand them and how to code them.......i was thinking that i can get some tips and ideas that will help me in ...

36. Out of Memory Exception when using Levenshtein Algorithm    coderanch.com

I am comparing two html files, using Levenshtein Algorithm. I am reading these two files in arraylist and giving as input to Levenshteing Algorithm. This algorithm uses Edit matrix for comparision with size m*n ( arrayList1.size() * arrayList2.size() ). It is working good and efficient for small files, but for large file it throws out of memory exception. To overcome this ...

37. minimax algorithm?!?!    coderanch.com

Sarah, Welcome to Java Ranch! I hope we can help you. In fact, I've tried to post an explanation several times, but I crashed the computer the first time and the second time I closed my browser on accident. I think there are plenty of resources on the Web that can explain it better than I can. Perhaps it will help ...

38. need help with java algorithm    coderanch.com

hi, i was going through java exercise and i did not understand this exercise. if you know anything, please post your comment here. Consider the usual algorithm for determining whether a sequence of parentheses is balanced. Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order). What is the maximum ...

39. Algorithm Help    coderanch.com

A friendly place for programming greenhorns! Register / Login Java Forums Java Java in General Algorithm Help Post by: John Brookes, Greenhorn on Apr 23, 2006 09:35:00 Righty-ho chaps, here's the situation: I'm creating a program that simulates traffic flow. I'm currently implementing speed limit zones. A "Limit" object (below) contains the value for the speed and a value ...

40. Garbage Collection Algorithm in Java 5    coderanch.com

41. Need help with Minimax Algorithm    coderanch.com

I am trying to implement a minimax algorithm based on this pseudo code below. Could anyone tell me if this pseudo code is correct, because I'm haivng a hell of a time getting it to work. Some things I don't get are: 1. In the MinMove function why do they use move > best_move (identical to max move). Shouldn't the min ...

42. MessageDigest with SHA 256 algorithm fails    coderanch.com

Hi, I need to generate a digest value for securing my message. I am using the follwing piece of code to generate the digest value using the MessageDigest class. import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.Security; public class message { static String a = "SHA-1"; static String b = "SHA-256"; public static void main (String arg[]){ try { MessageDigest digest = MessageDigest.getInstance(a); ...

43. from a round robin algorithm to best-fit    coderanch.com

Hi all, I am trying to develop a mechanism to know which machine can handle a user job (by providing his Requirements) for now I wrote this method but it is a Round robin, I am trying to modify it to a best-fit algorithm can anybody give me tips about how should I begin? public static String canDo(Resources userReq,Hashtable hash){ //getResourceInfo() ...

44. Powerset algorithm    coderanch.com

what Ernest is saying is that you can use the bits in an integer (or long) as "flags" for whether or not to include an element. say you have 3 elements. 2 ^ 3 = 8. so, you need to count from 0 - 7 (giving you the 8 powerset elements). as you count, you look at which bits in your ...

45. prims algorithm    coderanch.com

hi every1, im currently trying to do a very basic implementation of prims algorithm. At present i have an array of nodes (places) and edges (distances between the places) all within the form of an adjacency matrix. Iv now started Prims algorithm and i am trying to call the first node with the follwoing lines of code, altho it compiles and ...

46. Algorithm: Brightness Difference    coderanch.com

Dear Readers, I am using a program that allows the user to input two colors, one a Foreground color and the other a Background color. The program outputs whether the two colors have sufficient "color difference" and sufficient "brightness difference". If both conditions are fulfilled then these colors can be used as Foreground and Background colors. I analyzed the outputs for ...

47. Problem with my algorithm...    coderanch.com

Alright, I've been having some trouble with this. Basically, I need to read in 2 integers (for example, 10 and 15), then multiply them like so: a * a + 1 * ... b. So, for our example, we would need to multiply 10 x 11 x 12 x 13 x 14 x 15 and output the answer. Here's what I ...

48. Polynomial Algorithms    coderanch.com

Given that no-one else has replied, I suspect they all thought "WTF?", like I did. I think you're assuming that these "polynomial algorithms" are something well-known. But it doesn't look like anything I've ever seen and I did a fair amount of numerical computing. Please give some more background, then maybe we can help. (Yes, I do know what a "polynomial" ...

49. how to write sine wave algorithm code    coderanch.com

50. what algorithm does a Garbage collector use?    coderanch.com

Originally posted by ramanuja varun: Does the garbage collector use any algorithm? If yes please do mention that. Wow. Yes. It uses tons of algorithms.... Overall, the Sun GC breaks the heap into two generations. Young, which is generally for newer short lived objects. And Tenure, which objects gets promoted to after this lived for awhile. For the young ...

51. Problem with InsertionSort Algorithm    coderanch.com

Hello again, I've been revamping my Data Structures skills for a more modern JDK 1.5 (back in '96, when I was in college, I used GNU C in my Data Structures course). Reached a particular problem... Here's the TestCase: import junit.framework.TestCase; public class SortUtilTest extends TestCase { public void testInsertionSort() throws Exception { Integer[] is = { 5, 4, 1, 3, ...

52. Help me out to devise an algorithm for this    coderanch.com

In the following string: f b, b c, a c, e b, d a, g a two letters are tuples with each tuple separated by commas. The first letter in each tuple is a node and the second letter is the parent of the node. Please write a function that takes the string as input, and outputs a representation of the ...

53. Collective Intelligence in Action and Algorithms of the Intelligent Web    coderanch.com

Hi Satnam, Last time when I was visitng Manning's website I found that there are two similar titles scheduled to be published in 2008: one is your book and the other one is "Algorithms of the Intelligent Web". At first sight, these two titles seem to be very similar. What do you think? Will these two books cover the same stuff ...

54. Boyer-Moore Algorithm    coderanch.com

I reading the Wikipedia entry for the Boyer-Moore Algorithm for searching through strings, and I was wondering if someone can explain to me (in simple words with perhaps a simple example) of how the "good suffix shift" table is computed. I understand how the "bad character shift" table is calculated, but I can't seem to understand how the "good suffix shift" ...

55. suggest me a brief algorithm    coderanch.com

Welcome to JavaRanch. If I understand it correctly, then the keys of the Map are strings, and the values are the frequencies in which they occur? In that case, you can use a SortedMap instead of a HashMap. It keeps the elements in the natural order of their keys if you obtain an iterator from it.

56. bubble sort algorithm    coderanch.com

This is a standard algorithm for programming regardless of the language, C, C++, Pascal, Java, etc. As far as I know, there is no method in the java API called bubble sort. Check your local library for a book on algorithms to get the general concept. A good one is Data Structures & Algorighms in Java by Mitchell Waite.

57. matter about Algorithm    coderanch.com

58. Design question (algorithm)    coderanch.com

This question has always bothered me in a book I read a while ago and I can't find a proper solution. It's a program to convert a given number(integer) to roman numerals, for some reason I think I'm not doing this the most efficient way. Whenever code is repeated like this, there has to be something I missed. Loops aren't even ...

59. algorithm    coderanch.com

Hallo, I'd like to have some information on "2,3,4 Tree" algoithm and it's realization using Java. I tried to use Google but it was helpless or my request was not good enough. So i have nothing on this at the moment. I would be really appreciated if you posted some links about this algorithm.

60. Newton's square root algorithm    coderanch.com

For some reason this program spits out a bunch of errors in the DOS window, but none in my ide. Any noticeable problems with my code? import javax.swing.*; import BreezySwing.*; public class PIGuiNewton extends GBFrame{ private JLabel itLabel; private JLabel numLabel; private IntegerField itField; private IntegerField numField; private JButton itEnter; private int iterations, i, num; private double guess; public PIGuiNewton() { ...

61. Help in Algorithm Construction    coderanch.com

Hi everybody! I can't seem to figure out how to make an array of circles move! The problem requires me to animate a number of circles input by the user clockwise around a square of side 400 pixels with a 20 Milliseconds delay. At each move the circles must be capable of changing direction with probability input by the user at ...

62. Algorithms    coderanch.com

Given these 2 definitions of algorithm, your request may need to be a bit more specific. Gary. WordNet Dictionary Definition: [n] a precise rule (or set of rules) specifying how to solve some problem Computing Dictionary Definition: A detailed sequence of actions to perform to accomplish some task. Named after an Iranian mathematician, Al-Khawarizmi. Technically, an algorithm must reach a result ...

63. pseudocode and algorithm.    coderanch.com

Hi Rico, Welcome to JavaRanch! We don't like to hand out solutions to homework problems here. We do, however, like to help people figure them out for themselves. If you give it a try, and then show us what you've got, we'd be happy to critique it; if you get stuck, we'll be happy to give you a hint. If you ...

64. Algorithm vs. computer program    coderanch.com

in other words a computer program is a specific implementation of an algorithm or set of algorithms designed to be used in conjunction with computer hardware (and possibly other programs) to solve a problem whereas an algorithm does not define the way it is to be implemented (though specific algorithms might by their nature suggest specific implementations).

65. Algorithm problem (/w code)    coderanch.com

hello, im in the middle of making a program and have hit a strange problem which im sure you can me fix! :-) -i have a grid of squares and a jbutton. -when the button is pressed, a random number is made that decides the next step. - step A - adjacent squares change color, direction down, or right. - step ...

66. Algorithm for calculating    coderanch.com

Thanks for your reply. The Listener part is not the problem. I have done all that. Please take a look at what I have been trying to crack since Tuesday. I must say that this is neither a class assignment nor a project at work. I passed the scjp last December and the only way I can know my craft is ...

67. Line drawing algorithms    coderanch.com

Does anyone know the algorithm for drawing polygonal lines (ie: from (x1,y1) to (x2,y2) for any value of the x/y variables)? I can't use the Java libraries to do it because, to be honest, I'm doing it in C and I haven't got enough program memory to store the maths libraries. I haven't been able to find any algortihms on the ...

68. Anyone know an algorithm for this?    coderanch.com

hi, This is just a simple program that finds the adjcanet squares ofa selected square. As the range increases, so will the number of LOC, using my current method. anyone any ideas how to implement this in a nested loop? int x = currentUnit.unitCol; int y = currentUnit.unitRow; try { layerOneRef[x][y + 1].movePhase = true; } catch (ArrayIndexOutOfBoundsException e) {} try ...

69. Need help with algorithm    coderanch.com

OK, starting to actually put my project together and have been trying to figure out how I am going to accomplish the following: I have a tournament with 4 different divisions. Each of these divisions is made up of a varying number of teams (from 3 to 7 teams per division). Each team needs to race the other in a "Round ...

70. Question with an algorithm    coderanch.com

1) How to find 5 most frequent apprearance workds in a words array? what if the size of the array is so big that we only need ot find approximate 5 top popular words? 2) Assume speed is more important than storage. How do you count the number of bits that will set in 32 bit integer? Please help. Thanks!

71. need algorithm for arranging    coderanch.com

72. triangle algorithm    coderanch.com

I don't think there is a solution. A really small triangle, and a really large triangle, may have the same center. So almost any point can be in the triangle or not, depending on the size of the triangle. You don't know the size, only the center, so you can't tell if the point is in the triangle. Henry

74. Floyd's Algorithm    coderanch.com

Hi there! I'm witing because i've been working on a project, in this project The user has to give the initial city an the final. I've read about the Floyd's Algorithm. In my project i just have to use the final step of Floyd's Algorithm that is to check the final adjacency matrix, given by me. /* * Shortest Path Between ...

75. Algorithm: Brightness Difference    coderanch.com

Dear Readers, I am using a program that allows the user to input two colors, one a Foreground color and the other a Background color. The program outputs whether the two colors have sufficient "color difference" and sufficient "brightness difference". If both conditions are fulfilled then these colors can be used as Foreground and Background colors. I analyzed the outputs for ...

76. algorithms in java    coderanch.com

77. algorithm for addition using only bitwise operators    coderanch.com

This looks an awful lot like a homework problem. or at the very least, a theoretical exercise you have given yourself. So, it would be pointless at best, and cheating at worst for someone to give you the solution. So, what have you tried? where are you stuck? what do you think will or won't work, and why?

78. Average algorithm    coderanch.com

How to implement an algorithm that averages an array of N doubles, and is relatively free from bug? It should take care of overflows, and be reasonably fast. Simply accumulating and then divide is susceptible to overflow while dividing all values by N prior to summing them takes 2x the required operations to calculate. [ October 22, 2007: Message edited by: ...

79. Response to algorithms    coderanch.com

Just for clarification, I'm only asking out of academic curiosity. After I discovered the XOR swap algorithm I demonstrated my cleverness to my co-workers around the water cooler when the question of floats came up. The idea of converting the floats to integers doing the XOR swap and the converting back came up, but didn't seem like a good solution (figuring ...

80. Run-Time of the algorithm..    coderanch.com

You may prefer to use the System method which gets time in nanoseconds, called something like nanoTime() (look in the API for the correct spelling).long startTime = System.nanoTimeOrSimilar(); . . . carry out algorithm, or do nothing at all. . . . long runTime = System.nanoTimeOrSimilar() - startTime; System.out.printf("My algorithm took %d.%03d microseconds.%n", runTime / 1000, runTime % 1000);Also note how ...

81. Numerical algorithm help?(simple question)    coderanch.com

Matlab (like Mathematica) is a standalone program for solving math-related problems. It includes a complete programming language to do that. There's probably a Java API for it, too. It's not cheap, though. It would be easier to help you if you were more specific about what kinds or algorithms you'd like to implement - differentiation, integration, differential equations, ... ? You ...

82. Knuth-Morris-Pratt Algorithm    coderanch.com

Dear all, I want to implement KMP alorothem in Java. but i can not understand how it works. though i went through google, still the situation is same. can anybody help me in this matter. my basic problem is how to create the shifting table (in most web sites, next[]). Or can somebody direct me to a simple tutorial on KMP ...

83. Can anyone please help me urgently with the algorithm or code for this scenario.    coderanch.com

Write a java program using following details. You are free to make all necessary assumptions. All the assumptions made should be documented. There are four scientists who need to be ordered according to their smartness (smartest to least smart). There is a text file "smart.txt" in the following format: Satish Arun Ramesh Suresh Ramesh Satish Suresh Satish Each line has a ...

84. is thie the algorithm for cheking    coderanch.com

step1. mid_index = (total_length - 1)/2 (for odd) or (total_length/2)-1 for even step2. max_index = total_length - 1 (to pick up letters from end) step2. loop_index = 0 step3. pick letter at loop_index, pick letter at max_index - loop_index step4. compare them, if not equal, print "not palindrome" and exit. step5. loop_index = loop_index + 1 step6. if loop_index > mid_index ...

85. Ullman algorithm    coderanch.com

86. Looking for a leg up on an Anagram algorithm    coderanch.com

Howdy. I'm working on writing an anagram generator that can take a String, shuffle it around & compare the permutations of all the chars against entries in a known word list. I have a good start - I can perform a search against char permutations of the entire String, but I'm stuck as to how I should write the part that ...

87. Triangulation algorithm    coderanch.com

88. GCD calculation using Euclidean algorithm fails    coderanch.com

Hi, I have here a simple program to find the GCD - Greatest Common Divisor of 2 numbers using Euclidean algorithm. I guess that's the fastest way to compute GCD. Here is the code: public static void main(String[] args) throws IOException{ BufferedReader read = new BufferedReader(new InputStreamReader(System.in)); int diff=0; System.out.println("Enter num1: "); int x = Integer.parseInt(read.readLine()); System.out.println("Enter num2: "); int y ...

89. narrow down a range algorithm    coderanch.com

90. Newbie Question about the use of flow control algorithms    coderanch.com

I am new to java programing and algorithms I was going through the the java tutorial and was quite proud of myself as I was surviving chapt. 3 then I came across this demo and began to lose my footing Can you please help me by explaining these few lines of code in the ContinueWithLabelDemo? correct me if i am wrong ...

91. algorithm to compute the common space of two cuboid?    coderanch.com

the cuboid is specified by two vertex which are Point3D objects meaning that they are parallel to the axises. My approach is to first determine if the two cuboids have common space by compare the distance between two mid-point of the two cuboids with half of their length on the X,Y and Z axis respectively. If they do have common space, ...

92. Improving An Algorithm    coderanch.com

94. Token ring algorithm implementation    coderanch.com

i don't know if this is the right forum.I wish to implement the token ring algorithm for mobile hosts.I have information as below for the algorithm. A fundamental algorithm in distributed systems consists of circulating a token amongst participants in a logical ring. Each participant executes as follows: wait receipt of token from its predecessor in the ring; enter ...

95. Algorithm efficiency for making a Set    coderanch.com

import java.util.Arrays; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Set; import java.util.TreeSet; public class MainClass { static void fill(Set s) { s.addAll(Arrays.asList("one two three four five six seven".split(" "))); } public static void test(Set s) { System.out.println(s.getClass().getName().replaceAll("\\w+\\.", "")); fill(s); fill(s); fill(s); System.out.println(s); // No duplicates! s.addAll(s); s.add("one"); s.add("one"); s.add("one"); System.out.println(s); System.out.println("s.contains(\"one\"): " + s.contains("one")); } public static void main(String[] args) { test(new HashSet()); ...

96. implementing jacobi algorithm to implement laplace equation    coderanch.com

Hi folks , I have been trying to implement this algorithm and have been stuck up on with a error i.e Array index out of bounds exception. 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 a margin ...

97. Need some help with an algorithm    coderanch.com

Okay, so I'm sure I'm not thinking of something simple here, but here goes... The assignment was to take some input file and read it (which I have done, presumably correctly)... the file contains lists of people. The people can be sorted into two categories. Each person is followed by a secondary list of people which are in the "opposite" category ...

98. Combinations Algorithm    coderanch.com

I have a few Lists of Strings. for example: List AList contains {"a1","a2","a3","a4"} List BList contains {"b1","b2","b3"} List CList contains {"c1","c2","c3","c4","c5"} List DList contains {"d1","d2"} so on and so forth. The number of lists is variable and number of Strings in the list is also variable. I want to write a code that returns ALL POSSIBLE combinations under the following conditions: ...

99. Writing a compuer algorithm to solve a problem within 3 steps    coderanch.com

Hey there folks, for those who remember me, I posted a topic earlier this weekend on how to write a program that allows the user to take one set of toothpicks to another in order to solve it in 3 steps. The second part was having the computer solve the problem itself, which I also wrote. However, this 3rd step is ...

100. books on algorithms    coderanch.com

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.