-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsertSort.java
More file actions
57 lines (45 loc) · 814 Bytes
/
InsertSort.java
File metadata and controls
57 lines (45 loc) · 814 Bytes
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
48
49
50
51
52
53
54
55
56
57
public class InsertSort{
static int SIZE = 1000;
static Node []node = new Node[SIZE];
public class Node{
int data;
Node next;
Node(){
}
Node(int values){
this.data = values;
}
}
void init(){
for(int i=0;i<SIZE;i++){
node[i] = new Node();
node[i].data = 0;
node[i].next = null;
}
}
void insert(){
}
int getLastDistance(int []data,int x,int y){
int dis =99999,i,last =0;
for (i=0;i<data.length;i++){
if(data[i] == x || data[i]==y){
last = i;
i++;
break;
}
}
for(;i<data.length;i++){
if(data[i] == x || data[i] == y){
if(data[last] != data[i]&& i-last < dis){
dis = i - last;
last = i;
}else{
last = i;
}
}
}
return dis;
}
public static void main(String[] args)throws Exception {
}
}