Skip to content

Commit fcafb96

Browse files
Lenovo LYGLenovo LYG
authored andcommitted
做了第四代罗瑶光快排 思想 20190701
1 parent 7609c90 commit fcafb96

14 files changed

+309
-188
lines changed

DP/searchProcessor/BinarySearch.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package searchProcessor;
22
public class BinarySearch{
3-
public boolean search(int [] array,int n) {
4-
int low = 0;
5-
int high=array.length-1;
6-
while(low<high){
7-
int mid=(low+high)/2;
8-
if(array[mid]==n) {
3+
public boolean search(int [] array, int n) {
4+
int low= 0;
5+
int high= array.length- 1;
6+
while(low< high){
7+
int mid= (low+ high)/ 2;
8+
if(array[mid]== n) {
99
return true;
1010
}else {
11-
if(n<array[mid]) {
12-
high=mid-1;
11+
if(n< array[mid]) {
12+
high= mid-1;
1313
}else{
14-
low=mid+1;
14+
low= mid+1;
1515
}
1616
}
1717
}

DP/searchProcessor/BreadthRun.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,21 @@ private void pop() {
6868
}
6969
}
7070
head.value.sort=1;
71-
if(head.value.O1!=null&&head.value.O1.sort==0)
71+
if(head.value.O1!=null&&head.value.O1.sort== 0)
7272
push(head.value.O1);
73-
if(head.value.O2!=null&&head.value.O2.sort==0)
73+
if(head.value.O2!=null&&head.value.O2.sort== 0)
7474
push(head.value.O2);
75-
if(head.value.O3!=null&&head.value.O3.sort==0)
75+
if(head.value.O3!=null&&head.value.O3.sort== 0)
7676
push(head.value.O3);
77-
if(head.value.O4!=null&&head.value.O4.sort==0)
77+
if(head.value.O4!=null&&head.value.O4.sort== 0)
7878
push(head.value.O4);
79-
if(head.value.O5!=null&&head.value.O5.sort==0)
79+
if(head.value.O5!=null&&head.value.O5.sort== 0)
8080
push(head.value.O5);
81-
if(head.value.O6!=null&&head.value.O6.sort==0)
81+
if(head.value.O6!=null&&head.value.O6.sort== 0)
8282
push(head.value.O6);
83-
if(head.value.O7!=null&&head.value.O7.sort==0)
83+
if(head.value.O7!=null&&head.value.O7.sort== 0)
8484
push(head.value.O7);
85-
if(head.value.O8!=null&&head.value.O8.sort==0)
85+
if(head.value.O8!=null&&head.value.O8.sort== 0)
8686
push(head.value.O8);
8787
}
8888
}

DP/searchProcessor/DepthRun.java

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,73 +14,73 @@ public DepthRun(Leaf root, int n1) {
1414

1515
@Override
1616
public void run(){
17-
result=false;
17+
result= false;
1818
check(temp1);
19-
end=true;
19+
end= true;
2020
}
2121

2222
private void check(Leaf temp) {
23-
if(temp!=null){
24-
if(temp.sort==0){
25-
if(temp.hasO1==1){
26-
if(n == temp.value[0]){
27-
result=true;
28-
end=true;
23+
if(temp!= null){
24+
if(temp.sort== 0){
25+
if(temp.hasO1== 1){
26+
if(n== temp.value[0]){
27+
result= true;
28+
end= true;
2929
}
3030

3131
}
32-
if(temp.hasO2==1){
33-
if(n == temp.value[1]){
34-
result=true;
35-
end=true;
32+
if(temp.hasO2== 1){
33+
if(n== temp.value[1]){
34+
result= true;
35+
end= true;
3636
}
3737
}
38-
if(temp.hasO3==1){
39-
if(n == temp.value[2]){
40-
result=true;
41-
end=true;
38+
if(temp.hasO3== 1){
39+
if(n== temp.value[2]){
40+
result= true;
41+
end= true;
4242
}
4343
}
44-
if(temp.hasO4==1){
45-
if(n == temp.value[3]){
46-
result=true;
47-
end=true;
44+
if(temp.hasO4== 1){
45+
if(n== temp.value[3]){
46+
result= true;
47+
end= true;
4848
}
4949
}
50-
if(temp.hasO5==1){
51-
if(n == temp.value[4]){
52-
result=true;
53-
end=true;
50+
if(temp.hasO5== 1){
51+
if(n== temp.value[4]){
52+
result= true;
53+
end= true;
5454
}
5555
}
56-
if(temp.hasO6==1){
57-
if(n == temp.value[5]){
58-
result=true;
59-
end=true;
56+
if(temp.hasO6== 1){
57+
if(n== temp.value[5]){
58+
result= true;
59+
end= true;
6060
}
6161
}
62-
if(temp.hasO7==1){
63-
if(n == temp.value[6]){
64-
result=true;
65-
end=true;
62+
if(temp.hasO7== 1){
63+
if(n== temp.value[6]){
64+
result= true;
65+
end= true;
6666
}
6767
}
68-
temp.sort=1;
69-
if(temp.O1!=null&&temp.O1.sort==0)
68+
temp.sort= 1;
69+
if(temp.O1!= null&&temp.O1.sort== 0)
7070
check(temp.O1);
71-
if(temp.O2!=null&&temp.O2.sort==0)
71+
if(temp.O2!= null&&temp.O2.sort== 0)
7272
check(temp.O2);
73-
if(temp.O3!=null&&temp.O3.sort==0)
73+
if(temp.O3!= null&&temp.O3.sort== 0)
7474
check(temp.O3);
75-
if(temp.O4!=null&&temp.O4.sort==0)
75+
if(temp.O4!= null&&temp.O4.sort== 0)
7676
check(temp.O4);
77-
if(temp.O5!=null&&temp.O5.sort==0)
77+
if(temp.O5!= null&&temp.O5.sort== 0)
7878
check(temp.O5);
79-
if(temp.O6!=null&&temp.O6.sort==0)
79+
if(temp.O6!= null&&temp.O6.sort== 0)
8080
check(temp.O6);
81-
if(temp.O7!=null&&temp.O7.sort==0)
81+
if(temp.O7!= null&&temp.O7.sort== 0)
8282
check(temp.O7);
83-
if(temp.O8!=null&&temp.O8.sort==0)
83+
if(temp.O8!= null&&temp.O8.sort== 0)
8484
check(temp.O8);
8585
}
8686
}

DP/searchProcessor/LinerSearch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package searchProcessor;
22
public class LinerSearch{
33
public boolean search(int [] array,int n) {
4-
for(int i=0;i<array.length;i++){
5-
if(array[i]==n)
4+
for(int i=0; i<array.length;i++){
5+
if(array[i]== n)
66
return true;
77
}
88
return false;

DP/searchProcessor/PreorderTreeSearch.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package searchProcessor;
22
import sortProcessor.Leaf;
33
public class PreorderTreeSearch{
4-
public boolean search(Leaf root,int n1) {
5-
PreorderRun pr=new PreorderRun(root,n1);
6-
Thread t=new Thread(pr);
4+
public boolean search(Leaf root, int n1) {
5+
PreorderRun pr= new PreorderRun(root, n1);
6+
Thread t= new Thread(pr);
77
t.run();
88
while(true){
99
if(pr.end){

DP/searchProcessor/RandomSearch.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package searchProcessor;
22
public class RandomSearch{
33
public boolean search(int [] array,int n) {
4-
int ran[] = new int[array.length];
5-
java.util.Random r = new java.util.Random();
4+
int ran[]= new int[array.length];
5+
java.util.Random r= new java.util.Random();
66
int i=0;
7-
while(i<array.length){
8-
int j = r.nextInt(array.length);
9-
if(ran[j] == 0) {
10-
if(array[j] == n){
7+
while(i< array.length){
8+
int j= r.nextInt(array.length);
9+
if(ran[j]== 0) {
10+
if(array[j]== n){
1111
return true;
1212
}else{
13-
ran[j]=1;
14-
i+=1;
13+
ran[j]= 1;
14+
i+= 1;
1515
}
1616
}
1717
}

DP/sortProcessor/BBSort.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
package sortProcessor;
22
public class BBSort{
33
public int[] sort(int [] array) {
4-
for(int i=0;i<array.length;i++)
5-
for(int j=0;j<array.length-1;j++){
6-
if(array[j]>array[j+1]){
7-
int temp=array[j];
8-
array[j]=array[j+1];
9-
array[j+1]=temp;
4+
for(int i= 0; i<array.length; i++)
5+
for(int j= 0; j<array.length- 1; j++){
6+
if(array[j]>array[j+ 1]){
7+
int temp= array[j];
8+
array[j]= array[j+ 1];
9+
array[j+ 1]= temp;
1010
}
1111
}
1212
return array;
1313
}
1414

1515
public int[] sort(int [] array,int n) {
16-
for(int i=0;i<n;i++)
17-
for(int j=0;j<n-1;j++){
18-
if(array[j]>array[j+1]){
19-
int temp=array[j];
20-
array[j]=array[j+1];
21-
array[j+1]=temp;
16+
for(int i=0; i<n; i++)
17+
for(int j=0; j<n-1; j++){
18+
if(array[j]> array[j+ 1]){
19+
int temp= array[j];
20+
array[j]= array[j+ 1];
21+
array[j+ 1]= temp;
2222
}
2323
}
2424
return array;

DP/sortProcessor/BTreeSort.java

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,69 @@
11
package sortProcessor;
2-
public class BTreeSort
3-
{
2+
public class BTreeSort{
43
public Leaf root;
54
public Leaf heap;
65
int c;
76
int a1[];
87
public int[] sort(int [] a) {
98
//make tree
10-
c=0;
11-
a1=new int[a.length];
12-
if(root==null){
13-
root=new Leaf();
14-
root.value[0]=a[0];
15-
root.hasO1=1;
9+
c= 0;
10+
a1= new int[a.length];
11+
if(root== null){
12+
root= new Leaf();
13+
root.value[0]= a[0];
14+
root.hasO1= 1;
1615
}
17-
for(int i=1;i<a.length;i++){
18-
heap=root;
16+
for(int i= 1; i< a.length; i++){
17+
heap= root;
1918
addleaf(a[i]);
2019
}
21-
heap=root;
20+
heap= root;
2221
check(heap);
2322
return a1;
2423
}
2524
private void check(Leaf temp) {
2625
// TODO Auto-generated method stub
27-
if(temp!=null){
26+
if(temp!= null){
2827
check(temp.O1);
29-
a1[c]=temp.value[0];
30-
c+=1;
28+
a1[c]= temp.value[0];
29+
c+= 1;
3130
check(temp.O2);
3231
}
3332
}
3433
private void addleaf(int i) {
35-
if(i<=heap.value[0]){
36-
if(heap.O1==null){
37-
heap.O1=new Leaf();
38-
heap=heap.O1;
39-
heap.value[0]=i;
40-
root.hasO1=1;
34+
if(i<= heap.value[0]){
35+
if(null== heap.O1){
36+
heap.O1= new Leaf();
37+
heap= heap.O1;
38+
heap.value[0]= i;
39+
root.hasO1= 1;
4140
return;
4241
}
4342
else{
44-
heap=heap.O1;
43+
heap= heap.O1;
4544
addleaf(i);
4645
}
4746
}
4847
else{
49-
if(heap.O2==null){
50-
heap.O2=new Leaf();
51-
heap=heap.O2;
52-
heap.value[0]=i;
53-
root.hasO1=1;
48+
if(heap.O2== null){
49+
heap.O2= new Leaf();
50+
heap= heap.O2;
51+
heap.value[0]= i;
52+
root.hasO1= 1;
5453
return;
5554
}else{
56-
heap=heap.O2;
55+
heap= heap.O2;
5756
addleaf(i);
5857
}
5958
}
6059
}
6160
public Leaf root(int[] a) {
62-
if(root==null){
63-
root=new Leaf();
64-
root.value[0]=a[0];
65-
root.hasO1=1;
66-
}for(int i=1;i<a.length;i++){
67-
heap=root;
61+
if(root== null){
62+
root= new Leaf();
63+
root.value[0]= a[0];
64+
root.hasO1= 1;
65+
}for(int i=1; i<a.length; i++){
66+
heap= root;
6867
addleaf(a[i]);
6968
}
7069
// TODO Auto-generated method stub

0 commit comments

Comments
 (0)