hi i have question about Batcher's odd-even sort i have following code
public class Batcher{
public static void batchsort(int a[],int l,int r){
int n=r-l+1;
for (int p=1;p<n;p+=p)
for (int k=p;k>0;k/=2)
for (int j=k%p;j+k<n;j+=(k+k))
for (int i=0;i<n-j-k;i++)
if ((j+i)/(p+p)==(j+i+k)/(p+p))
exch(a,l+j+i,l+j+i+k);
}...
Hi
I have found this code in the internet and it was for arrays ,I want to change it for doubly linked list(instead of index we should use pointer) would you please help me that how can i change merge method(I have changed sort method by myself) also this is not my home work ,I love working with linked list!!
public class MergeSort {
p...
For example, we have the following array:
char data[]=new char[]{'A','S','O','R','T','I','N','G','E','X','A','M','P','L','E'};
and an index array:
int a[]=new int[]{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14};
void insitu (char data[], int a[], N)
{
for (int i=0;i<N;i++)
{
char v=data[i];
int j, int k;
for (...
Hello,
I have the following problem:
Given N objects of different values (N < 30, and the values are multiple of a "k" constant, i.e. k, 2k, 3k, 4k, 6k, 8k, 12k, 16k, 24k and 32k), I need an algorithm that will distribute all items to M players (M <= 6) in such a way that the total value of the objects each player gets is as even as p...
hi i have write following code which prints elements in sorted order only one big problem is that it use two additional array
here is my code
public class occurance{
public static final int n=5;
public static void main(String[]args){
// n is maximum possible value what it should be in array suppose n=5 then array may be
...
Hi all
I want to know if Donald Knuth has covered the disjoint set in his great book ? If so, which chapter is it?
Best Regards,
...
I've got an assignment I can't figure out, any pointers will be much appreciated, it goes like so:
There's a series of light bulbs represented as an array of true/false, there's a switch for every light bulb, by clicking it for any light bulb, you toggle it as well as 2 adjacent ones (1 from left & another 1 from right; if clicked switc...
Can anyone suggest some clustering algorithm which can work with distance matrix as an input? Or the algorithm which can assess the "goodness" of the clustering also based on the distance matrix?
At this moment I'm using a modification of Kruskal's algorithm (http://en.wikipedia.org/wiki/Kruskal%27s_algorithm) to split data into two clu...
Hi all ,
i cannot understand a certain part of the paper published by Donald Johnson about finding cycles (Circuits) in a graph.
More specific i cannot understand what is the matrix Ak which is mentioned in the following line of the pseudo code :
Ak:=adjacency structure of strong component K with least
vertex in subgraph of G ind...
I want to apply machine learning to a classification problem in a parallel environment. Several independent nodes, each with multiple on/off sensors, can communicate their sensor data with the goal of classifying an event as defined by a heuristic, training data or both.
Each peer will be measuring the same data from their unique persp...
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 my work.
I've coded the algorithm as shown in The Handbook of Applied Cryptography by Menezes, et al. Unfortunately for me, I do not get the correct outcome f...
I have the following code:
public class LSD{
public static int R=1<<8;
public static int bytesword=4;
public static void radixLSD(int a[],int l,int r){
int aux[]=new int[a.length];
for (int d=bytesword-1;d>=0;d--){
int i, j;
int count[]=new int[R+1];
for ( j=0;j<R;j++) co...
I need to produce the schedule of a sport-event.
There are 30 teams. Each team has to play 8 matches. This means that it is not possible for each team to compete again all other teams, but I need to avoid that two team compete more than once against each other.
My idea was to generate all possible matches (for 30 teams: (30*29)/2 = 435...
Is there utility program for Page replacement algorithm simulation in Java?
...
I'm having some problems deleting a node from a skip list. I have the following structures:
struct Node
{
int info;
Node **link_;
Node(int v, int levels)
{
info = v;
link_ = new Node*[levels];
for ( int i = 0; i < levels; ++i )
link_[i] = NULL;
}
};
struct List
{
int H; // l...
Right now I have
private static void iterateall(BinaryTree foo) {
if(foo!= null){
System.out.println(foo.node);
iterateall(foo.left);
iterateall(foo.right);
}
}
Can you change it to Iteration instead of a recursion?
...
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 by tracing chains of references from the roots.
Reference counting is expensive – it needs action every time a reference changes and it doesn’t spot cyclical structur...
I cannot find any complete description about LL(*) parser, such as ANTLR, on Internet.
I'm wondering what is the difference between an LL(k) parser and an LL(*) one and why they can't support left-recusrive grammars despite their flexibility.
...
Hey,
How is it possible to sort data from multiple tables by relevance?
My table structure is following:
I have 3 tables in my database, one table contains the name of solar systems, the second for e.g. of planets. There is one more table, witch is a connection between solar systems and planets.
If I want to get data of a planet, witc...
I have a list of tuples.
[
"Bob": 3,
"Alice": 2,
"Jane": 1,
]
When incrementing the counts
"Alice" += 2
the order should be maintained:
[
"Alice": 4,
"Bob": 3,
"Jane": 1,
]
When all is in memory there rather simple ways (some more or some less) to efficiently implement this. (using an index, insert-sort etc) The que...