Browse files

wqq

  • Loading branch information...
1 parent 3dea61d commit 87184ffb19735b09a6d77eb88316cba5c71b4b3f @willawill committed Dec 28, 2011
View
BIN FloydWarshall.class
Binary file not shown.
View
11 FloydWarshall.java
@@ -62,12 +62,11 @@ public static void main (String[] argv)
System.out.println(x);
// A test case.
double[][] adjMatrix = {
- {0, 4, x, 2, 5, x},
- {4, 0, 2, x, 2, 6},
- {x, 2, 0, 1, x, 2},
- {2, x, 1, 0, -3, x},
- {5, 2, x, -3, 0, -1},
- {x, 6, 2, x, -1, 0},
+ {0, 10, x, 5, x},
+ {10, 0, 5, 5,10},
+ {x, 5, 0, x, x},
+ {5, 5, x, 0, 20},
+ {x, 10, x, 20, 0},
};
View
BIN MergeSort.class
Binary file not shown.
View
37 Permutations.java
@@ -1,32 +1,41 @@
+import java.util.*;
public class Permutations {
public int count = 0;
- public void perm1(String s) { perm1("", s);
- System.out.println(count);
-
+ private ArrayList<String> permutations;
+
+ public Permutations(){
+ this.permutations = new ArrayList<String>();
+}
+ public void perm1(String s) {
+ perm1("", s);
+ Iterator i = this.permutations.iterator();
+ while (i.hasNext()){
+ System.out.println(i.next());
+}
}
private void perm1(String prefix, String s) {
- this.count++;
-
+
int N = s.length();
- System.out.println("String is " +s);
- if (N == 0)
- System.out.println(prefix);//All the chars are printed out.
+// System.out.println("String is " +s);
+ if (N == 0){
+ this.permutations.add(prefix);//All the chars are printed out.
+ }
else {
for(int i = 0; i < N; i++){
- System.out.println("i is " + i +" prefix is "+ prefix);
- return perm1(prefix + s.charAt(i), s.substring(0, i) + s.substring(i+1, N));
+// System.out.println("i is " + i +" prefix is "+ prefix);
+ perm1(prefix + s.charAt(i), s.substring(0, i) + s.substring(i+1, N));
}
}
}
- public int getCount(){
- return count;
+ public ArrayList<String> getPermu(){
+ return this.permutations;
}
public static void main(String[] args) {
Permutations p = new Permutations();
- String alphabet = "Teeee";
- System.out.println(alphabel);
+ String alphabet = "Te";
+
p.perm1(alphabet);
}
}
View
BIN ReverseString.class
Binary file not shown.
View
22 ReverseString.java
@@ -1,5 +1,3 @@
-import junit.framework.*;
-
public class ReverseString{
private String s;
@@ -33,7 +31,7 @@ public String ReverseString2(){//Swap the array,
return new String(chars);
}
-public String Reverse3()//XOR
+public String Reverse3(String s)//XOR
{
if (null==s|| (s.length()<1)){
return s;
@@ -53,23 +51,25 @@ public String Reverse3()//XOR
public static void main(String[] args){
- String s = "wawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny frawaalfdlakjlkjlkj2340980 ou5094811098309 kjlk20394 lkj24-94 aution: A C/C++ function or Java method based on this descriptionwill be hopelessly inefficient, unless n is very small. If we attempt tocompute F200 (a 41-digit number) using such a function, the program willnot finish in the lifetime of the earth, even with a computer millions oftimes faster than present ones. By contrast, with the iterative algorithmbelow, we can compute F200 easily in a tiny fr";
+ String s = "hello world";
ReverseString rs = new ReverseString(s);
long start = System.nanoTime();
String s1 = rs.ReverseString();
long end = System.nanoTime();
-System.out.println(end - start);
- start = System.nanoTime();
- String s2=rs.ReverseString2();
- end = System.nanoTime();
-System.out.println(end - start);
+//System.out.println(end - start);
+// start = System.nanoTime();
+// String s2=rs.ReverseString2();
+// end = System.nanoTime();
+//System.out.println(end - start);
start = System.nanoTime();
- String s3 = (rs.Reverse3());
+ String s3 = (rs.Reverse3(s));
+ String s4 = (rs.Reverse3(s3));
end = System.nanoTime();
System.out.println(end - start);
-System.out.println(s.length());
+System.out.println(s3);
+System.out.println(s4);
}
}
View
BIN Stack.class
Binary file not shown.
View
BIN power.class
Binary file not shown.

0 comments on commit 87184ff

Please sign in to comment.