-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLSD.java
More file actions
47 lines (45 loc) · 1.36 KB
/
LSD.java
File metadata and controls
47 lines (45 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.util.Random;
public class LSD{
public static void sort(String[] a,int w){
int N=a.length;
int R=256;
String[] aux=new String[N];
for (int i=w-1;i>=0;i--){
int[] count=new int[R+1];
for (int j=0;j<N;j++){
char r=a[j].charAt(i);
count[r+1]++;
}
for (int k=0;k<R;k++){
count[k+1]+=count[k];
}
for (int m=0;m<N;m++){
char r=a[m].charAt(i);
aux[count[r]]=a[m];
count[r]++;
}
for (int p=0;p<N;p++){
a[p]=aux[p];
}
}
}
public static void main(String[] args){
Random r = new Random();
int V=100;
int L=7;
String[] str={"a","b","c","d","e","f","g","h","i","j","k",
"l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
String[] string=new String[V];
for (int i=0;i<V;i++){
String a="";
for (int j=0;j<L;j++){
int alpha=r.nextInt(26);
a+=str[alpha];
}
string[i]=a;
}
sort(string,L);
String st="qwert";System.out.println(st.charAt(2));
//for (String word:string) System.out.println(word);
}
}